Jump to content
Sign in to follow this  
cyber0ne

Extend Parent div Around Floated Child div?

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

Share this post


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>

:)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...