Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot make containing div height equal to absolutely positioned div

Status
Not open for further replies.

roblasch

Programmer
Joined
Dec 30, 2000
Messages
168
Location
US
Is it possible to make a containing div (in this instance #mainBody) the height of the elements in it. Right now i have some contents of the div spilling out of the bottom. The problem is that some of the elements are absolutely positioned. So my question boils down to this. If I have a div containing text with a left padding of 200px and then I position a menu absolutely on the left side of the div, can I make the div that contains the text longer than the menu? If it is possible, would it then be possible to float an element on the right in the div and make the containing div as long as whichever element reaches further down the page?
 
First question, no. There is no way you can make container react to the height of the absolutely positioned element. You could add min-height attribute to the parent, ensuring its height does not fall below certain value. IE however, does not support this setting, thus for that browser, height must be used instead.

Second question, yes. If there is an element following floated elements and was forced to clear (has attribute clear with a value of left, right or both, whichever applies), that element will be put right under the longest floated element. This element is in normal document flow, thus the parent element will extend to the point where this element ends.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top