开发者

set size of div based on floating element inside

开发者 https://www.devze.com 2023-03-09 22:44 出处:网络
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 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 floated 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

0

精彩评论

暂无评论...
验证码 换一张
取 消