Html 父div比子div小?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11126557/
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
Parent div is smaller than child div?
提问by user1440480
here's my question, i want to fill the content div
with white. BUT when i do it , its not filling the whole div. The child div are more bigger and they go over the parent div (content). I want that the content div cover all the child div.
这是我的问题,我想content div
用白色填充。但是当我这样做时,它没有填满整个 div。子 div 更大,它们越过父 div(内容)。我希望内容 div 覆盖所有子 div。
Here's my code
这是我的代码
#content {
width: 100%;
min-height: 400px;
height: auto;
max-height: 2000px; /* ONLY FOR THE MOMENT */
margin-top: -7px;
background:white;
}
#fastMenu {
float:left;
width: 200px;
height: 100%;
margin-top: 20px;
}
#contenu {
float:left;
width: 430px;
height: 100%;
margin-top: 20px;
background:white;
}
<div id = "content">
<div id = "fastMenu">
<a href="conseil-d-administration">
<img src="<?php echo 'http://dev201.viglob.gtvr.com/client_file/themes/default/interface/FR/menuAdmin.png'; ?>" border="0" />
</a>
<a href="congres-2012">
<img src="<?php echo 'http://dev201.viglob.gtvr.com/client_file/themes/default/interface/FR/menuCongres.png'; ?>" border="0" />
</a>
<a href="formation">
<img src="<?php echo 'http://dev201.viglob.gtvr.com/client_file/themes/default/interface/FR/menuFormation.png'; ?>" border="0" />
</a>
<a href="devenir-membre">
<img src="<?php echo 'http://dev201.viglob.gtvr.com/client_file/themes/default/interface/FR/menuMembre.png'; ?>" border="0" />
</a>
</div>
<div id="contenu" class="txt"></div>
</div>
I want also a cross-browsing answer please (IE7, IE8, IE9, Firefox, Chrome, Opera)
我还想要一个跨浏览的答案(IE7、IE8、IE9、Firefox、Chrome、Opera)
回答by Rodolfo
add overflow: auto
to the css for .content
添加overflow: auto
到 css 中.content