Reputation: 20745
I have one container div which contain 2 dynamic height (height haven't been set) divs side by side , those 2 divs are content divs , sometimes one div have more content than which cause to be more long from the other one , and those two divs have different color , in order to have Aesthetic page view i want those two divs to have equal height
how can i do this without involve javascript?
<div style="width:100px;border:1px solid black;">
<div style="width:50px;background-color:blue;float:left;">a <br/> b</div>
<div style="width:50px;background-color:red;float:left;">a</div>
<div style="clear:both"></div>
</div>
in the example above you can see that the blue div is bigger than the red div because it contain more content , what i want to do is what ever content the other div have the both divs have equal height and be look with similar size.
thank you in advance.
Upvotes: 1
Views: 341
Reputation: 850
Or look into this: http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks
Upvotes: 0
Reputation: 92803
You can use display:table
property for this:
.parent{
width:100px;
display:table;
border:1px solid green;
}
.child{
width:50px;
background:blue;
display:table-cell;
}
.child + .child{background:red;}
Upvotes: 3
Reputation: 5533
I don't think it is possible without Javascript for this situation. But you can handle if you use tables.
Upvotes: 0