Jump to content

Matching the height of a neighboring <div>.


sepoto

Recommended Posts

I would like the height of my narrow div to mimic the height of the div right next to it. The wide div has a flexible height. So essentially I want the narrow div to have the height of the wide div even if the narrow div has nothing in it. The narrow div will always be empty except for a background image. I kept the code short. The full version is essentially the WordPress SandBox v1.6 framework theme.Thanks!

<?php get_header() ?><div id="container"><div style='float: right; height: 100%; width: 75px; background-color: black; -moz-box-sizing: border-box; border: solid 1px black;'>fdsafdsafdsafdas</div><div style='float: right; width: 80%;'>Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battlefield of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.But, in a larger sense, we cannot dedicate—we cannot consecrate—we cannot hallow—this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us—that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion—that we here highly resolve that these dead shall not have died in vain—that this nation, under God, shall have a new birth of freedom— and that government of the people, by the people, for the people, shall not perish from the earth.</div></div><!-- #container --><?php get_footer() ?>

Link to comment
Share on other sites

using 100% height for narrow div will not work, UNLESS, body, html and container are also set to 100%, but as it seems you have a header, this becomes more complicated as the height of the header will be added to the 100% height. The better option is to give the illusion that narrow div is the same height of the content container by adding the background image intended for the narrow div, to the background of the content container itself, or another outer container wrapping this, then use background positioning to place it behind the narrow div.

Link to comment
Share on other sites

using 100% height for narrow div will not work, UNLESS, body, html and container are also set to 100%, but as it seems you have a header, this becomes more complicated as the height of the header will be added to the 100% height. The better option is to give the illusion that narrow div is the same height of the content container by adding the background image intended for the narrow div, to the background of the content container itself, or another outer container wrapping this, then use background positioning to place it behind the narrow div.
a combination of both these solutions might work...but...your math does not add up to 100%the right is 75px and the middle is 80% which always leaves SOME on the left.however, you still have options:
<div id="container" style="background-color:black; height:100%"><div style='float: right;  width: 75px; background-color: black; -moz-box-sizing: border-box; border: solid 1px black;'>fdsafdsafdsafdas</div><div style='float: right; width: 80%; background-color:white;'>Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, .....etc

here the black background is on the container AND on the right DIV. Whichever is longer will carry the black to the bottom. However, you still have black on the left. You can take care of this by using a background image (only) on the container, 75px wide solid black...and fixing the background top right and repeat-y.This will also avoid the black stripe across the middle bottom when the middle is not 100% of the screen height.Guy

Link to comment
Share on other sites

Hang on! we seem to have an echo here, Again!.Hang on! we seem to have an echo here, Again!.Hang on! we seem to have an echo here, Again!.Hang on! we seem to have an echo here, Again!.Hang on! we seem to have an echo here, Again!.all you have to do is make sure the background image placed in the outer container/s matches the width of narrow iv and repeat down and position it, no background image for other container is require, DONE!

Link to comment
Share on other sites

Hang on! we seem to have an echo here, all you have to do is make sure the background image placed in the outer container/s matches the width of narrow iv and repeat down and position it, no background image for other container is require, DONE!
ooopshazard of taking 2 hours to compose a reply - isn't multitasking fun -another answer wedges in between and then it sounds like I was not listening....
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...