Jump to content

Extend Parent div Around Floated Child div?


cyber0ne

Recommended Posts

Suppose I have the following:

<style type="text/css">#parent{  width: 750px;  margin: auto;}#child{  float: right;  width: 250px;}</style><div id="parent">  ...  <div id="child">    ...  </div></div>

In IE, the parent div extends down to fully encompass the child div, even if the child's content is longer than the parent's. But in more standards-compliant browsers, the parent div ends when its non-child content ends, and if the child is longer it extends down out of the parent.Is there any way in CSS to specify the behavior being seen in IE? That is, to have the parent div always fully encompass the child div within its padding, even though it's floated?-cyber0nehttp://www.cyber0ne.com

Link to post
Share on other sites
Suppose I have the following:
<style type="text/css">#parent{  width: 750px;  margin: auto;}#child{  float: right;  width: 250px;}</style><div id="parent">  ...  <div id="child">    ...  </div></div>

In IE, the parent div extends down to fully encompass the child div, even if the child's content is longer than the parent's.  But in more standards-compliant browsers, the parent div ends when its non-child content ends, and if the child is longer it extends down out of the parent.Is there any way in CSS to specify the behavior being seen in IE?  That is, to have the parent div always fully encompass the child div within its padding, even though it's floated?-cyber0nehttp://www.cyber0ne.com

I hope this is what u needput overflow:hidden; in the div that need to stretchotherwise u can put a <br style="clear:right" /> AFTER the floating DIV
<style type="text/css">#parent{ width: 750px; margin: auto; overflow:hidden; background-color:#F00;}#child{ float: right; width: 250px; background-color:#0F0;}</style><div id="parent"> ...Parent <div id="child">   ...Child </div><!-- <br style="clear:right" /> THIS br u can use if your not want 2 use the overflow:hidden; in the parent div --></div>

:)

Link to post
Share on other sites

Archived

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

×
×
  • Create New...