gpt4 book ai didi

css - 使内容
填充具有可变高度标题的容器

转载 作者:太空宇宙 更新时间:2023-11-04 00:07:46 25 4
gpt4 key购买 nike

我觉得我不应该问这么简单的问题,但我找不到任何简单的答案。

我有一个可以是任意高度的页眉。它下面的内容需要填满页面的剩余空间(两者都包含在一个必要的容器div中)。如何使用 HTML 和 CSS 实现这一点?我会考虑 JavaScript,但我希望在添加内容或调整窗口大小时等时自动调整大小。

HTML代码:

<div id="container" >

<div id="header" >
<br/>
<br/>
...variable content in the header (not necessarily text)...
<br/>
<br/>
</div>

<div id="content"></div>

</div>

CSS 代码:

#container
{
background-color:blue;
width:100%;
height:100%;
}

#header
{
background-color:green;
width:100%;
height:auto;
}

#content
{
background-color:red;
width:100%;
height:100px; /*The height here needs to fill the remaining space in the container div*/
}

最佳答案

我认为这可能有助于做您想做的事:http://jsfiddle.net/AGLDV/3/

html, body {
height:100%;
}

#container {
width:100%;
height:100%;
background:#ccc;
display:table;
}

#header {
height:1%;
width:100%;
background:blue;
display:table-row;
}

#content {
width:100%;
background:red;
display:table-row;
}

关于css - 使内容 <DIV> 填充具有可变高度标题的容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14276074/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com