Floated Div That Fills Remaining Width Of Parent
Solution 1:
I fiddled something for you: http://jsfiddle.net/mac_cain13/K5fJP
The .foo div has a min-width
to make sure it will go to the next line there is less then 50px available. The overflow: hidden;
makes sure the div is not behind the .child div.
I added some JavaScript to demo the behavior when .child gets wider. Click the .child div to add some pixels to it's width. When the .child div takes so much space that there is less then 50px left the .foo div will jump to the next line.
Pure CSS, but only tested in Safari. :)
Solution 2:
There are CSS hacks available when you know the width of the others. Or you could just use a table. But there is no concept in CSS such as "width: 100% - otherelement.width", this only works in JavaScript.
Solution 3:
Check this out
It's working now
http://jsfiddle.net/mikulgohil/fdVws/
HTML code:
<divclass="container"><divclass="child">First</div><divclass="foo">Second</div></div>
CSS code:
.container {
width: 300px;
overflow: auto;
background:#ff00dd;
}
.child {
float: left;
background:#ff0;
}
.foo {
background:#0033dd;
}
Post a Comment for "Floated Div That Fills Remaining Width Of Parent"