我经历了许多帖子看,仍然不能得到这个工作...如何使div内容适合高度为100%的父div?
我的目标是要风格的CSS(不使用JavaScript的),使DIV类的高度“两个”始终融入DIV类“容器”。
容器DIV的高度可能会改变,如窗口调整大小,这就是为什么我希望我的“两个”DIV能够相应地更改大小。因此,我将容器DIV高度设置为300像素,但它可以是像500像素等任何像素。
如果您需要更多说明,请让我知道。提前致谢!
HTML
<div class='container'>
<div class='top'>some text</div>
<div class='bottom'>
<div class='one'>header</div>
<div class='two'>items here</div>
</div>
</div>
CSS
.container
{
height: 300px;
width: 100%;
border: 3px solid red;
}
.top
{
height: 60px;
width: 100%;
background-color:pink;
float:left;
}
.bottom
{
width: 100%;
height: 100%;
background-color: green;
float: left;
}
.one
{
width: 100%;
height: 30px;
background-color: orange;
}
.two
{
width: 100%;
height: 100%;
background-color: yellow;
overflow: auto;
}
解释它简单的话。 –
你说你想让class .two适合类.container,但是.two是.bottom div的孩子。那么你想如何让布局看起来像? – Stano
@Stano:只要.two不会覆盖.container –