CSS Help
- Started
- Last post
- 6 Responses
- elee
Quick question that's driving me crazy: if I have a div with a background color, and then a child div with a float declaration, is there any way to keep the background of the parent div from clearing? example is here: http://pastie.org/1036779
- Continuity0
<div style="background-color:#F00">
<div style="float:left; background-color: inherit;"> Background isn't red</div>
</div>
- elee0
hm, that works, but I guess that my bigger issue is that the parent div isn't expanding to the height of the children when the float is there. Do you know of any way to get around this?
- foobaz0
You need to clear floated elements.
I think this is what you're looking for:
<div style="background-color:#F00">
<div style="float:left">Background isn't red</div>
<div style="clear:both;"></div>
</div>
- Continuity0
Yup, clearfix.
- airey0
if i understand what you mean then you need to add a clearing float div(selector) under the child div inside the parent div. look it up via google and see if thats what you need.
- elee0
ahh, that did the trick. Thanks everybody