HTML:
<ul>
<li>
<div class="one">Variable Height Title</div>
<div class="two">Fixed height middle block</div>
<div class="three">Variable height middle block<br />more content<br /> more contentmore content<br /> more content<br /> more content</div>
<div class="four">Fixed height footer</div>
</li>
<li>
<div class="one">Variable Height Title Might be two lines long</div>
<div class="two">Fixed height middle block</div>
<div class="three">Variable height middle block</div>
<div class="four">Fixed height footer</div>
</li>
<li>
<div class="one">Variable Height Title</div>
<div class="two">Fixed height middle block</div>
<div class="three">Variable height middle block</div>
<div class="four">Fixed height footer</div>
</li>
</ul>
CSS:
li {
float:left;
width:33%;
}
.one, .three {
background-color:blue;
}
.two, .four {
background-color:green;
}
Please look at this example: http://jsfiddle.net/WffHD/
Is there a way with css only to make the "one" divs equal height (which must be dynamic), and then also make all three columns equal height based on the tallest one as well? Another way of putting it: I want all "one" divs to be equal height, and then all columns should also be equal height by stretching the height of the "three" div. Unfortunately they must stay as li items due to a plugin I am using. I think this could be accomplished fairly easy with javascript but am looking for a css solution if possible. (Caveat, needs to work in IE7) Hope that makes sense and thanks!
After edit. In stead of using height, just use vertical-align. (works in css tables)
http://jsfiddle.net/wC4RF/4/
With great difficulty, or with JavaScript.
This is actually one of the things Flex Box Layout was designed for. So you would have something like this:
And it should give all the elements the same height. See the full Flex Box Layout specification for more options.
Just make sure you have the appropriate vendor prefixes, and you're good to go.
For a jQuery solution (this could possibly be rewritten to just javascript):
Look at this post by Matthew James Taylor. It's kinda complex to do it with CSS. But that's the only "nice" way. You could also use javascript and calculate the highest column and apply this height to the other two.
You need several Container like this:
Than you need to reposition each column:
There is two aspects for attention in this question:
1- equal heights for
li
's2- equal heights for the first divs
here is the first step:
there is a simple but trickery pure css solution which is valid and works great in IE6+ (i have tested it before) but needs a little bravory and markup.
first:
it is so simple we are forcing the height of the columns to be extremely tall, and then cutting them off with the hidden overflow, then we force the columns taller with a huge amount of bottom padding, and again we reduce the height of the wrapper back up with an equal amount of negative bottom margin. This gives us just the effect we need.
and for the second part truly the only way i could achieve is only by cutting them off the structure and put them in another structure like the above mentioned and so with a little css magic it seems that they both are only one structure(assuming you dont want to use js for this).
hope it helps.
For IE7?
And Pure CSS?
And All Row 1 (Div "one") Equal Height?
And all Columns Equal Height?
The answer is... Not possible.