I am building a small html web page. In my web page I've got a div, inside it I've got a floating div. I'd like to get the height of my wrapper div to be similar to that of my floating div. How can this be done in css \ html?
开发者_如何学PythonThank you
From your question, I'm guessing the problem is that your containing div
looks like this:
http://jsfiddle.net/RkHa4/ - it's not extending to the height
of the float
ed div
.
The solution is to "clear your floats".
An easy way to do this is to apply overflow: hidden
to your containing div
, like this:
http://jsfiddle.net/RkHa4/1/
Thirtydot is correct, you should clear your floats, but I would recommend you use the clearfix method instead. Using overflow:hidden
will cause unintended problems with CSS properties that extend past the boundaries of a container.
CSS overflow issue
精彩评论