Reputation: 503
Sorry. I had to edit my question: I made the second image in Photoshop.
**I am trying to find a DIV equivalent to a Table. How do you get divs to behave like TDs: All TDs adjust their height as the content grows, and all TDS have the same height to the bottom of the Table element. ** Why is this so hard with DIVs? After all these years, is'nt there a standard solution?
Upvotes: 4
Views: 16865
Reputation: 4439
yeah, your concept appears really tough to accomplish in CSS alone, for some reason. JQuery could handle it a lot better if you're open to it.
At any rate, here is is another alternative. It uses a clever trick as follows:
#container div { float: left; background: #ccc; width: 200px; margin-bottom: -2000px; padding-bottom: 2000px; }
Check it out here: http://jsfiddle.net/jplew/yPMVJ/
Upvotes: 6
Reputation: 4439
I mocked up a solution on JSfiddle using simple percentages: http://jsfiddle.net/xLSQX/
Otherwise, as mentioned above pay attention to the overflow:
attribute and clear: both
.
I want all the divs inside the container to act like table cells and the outer div to act like the element. The height of the outer div to be flexible and adjust to the height of all the content inside the other divs.
Upvotes: 0
Reputation: 18008
Possibly you have float
s in the children divs. In that case you can do either of the followings:
overflow:auto;
to the parent div's style. clear:both
style like the answer above.Upvotes: 1
Reputation: 484
try this
<div name="outer">
<div name="inner>put your contents here</div>
<div style="clear: both"></div>
</div>
you need a div that has the "clear:both" style (clear both simple makes the div takes up a entire line, nothing can float around it) at the very end of your inner divs so the outer div knows to extend to the end.
Upvotes: 2