CSS 使包装 div 扩展到与内容 div 相同的高度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2321034/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Making wrapper div extend to same height as content divs
提问by jerrygarciuh
I have a wrapper div with a min-height set. Position is relative and display is block. I have two column divs floated left and set to inherit min-height.
我有一个最小高度集的包装 div。位置是相对的,显示是块。我有两列 div 向左浮动并设置为继承最小高度。
When I have lengthy content the background color of #wrapper never extends to match the content in the column divs.
当我有冗长的内容时,#wrapper 的背景颜色永远不会扩展以匹配列 div 中的内容。
Page is here: http://youngimaginations.dreamhosters.com/index.php
页面在这里:http: //youngimaginations.dreamhosters.com/index.php
CSS is here: http://youngimaginations.dreamhosters.com/yi.css
CSS 在这里:http: //youngimaginations.dreamhosters.com/yi.css
Can someone point out the error of my ways?
有人可以指出我方法的错误吗?
回答by Pekka
overflow: auto
will do the trick
overflow: auto
会做的伎俩
or a <div style='clear: both'>
after the floated elements.
或<div style='clear: both'>
浮动元素之后。