我想在单个网页上使用 HTML 和 CSS 实现以下行为
我得到了前三个区域(黑色、红色、蓝色)的工作,但我遇到了可滚动内容(绿色)的问题。它适用于静态高度,但我不知道如何动态填充页面的其余部分。
这是我得到的
<div class="body">
<div class="menu">
menu
</div>
<div>
<div class="dynamiccontent">
<div class="errorheader">
Errors
</div>
<div class="errorcontent">
errors
</div>
<div class="fixedtext">
some text
</div>
<div class="fillcontent">
fillcontent
</div>
</div>
</div>
.body
{
background:red;
margin:0 auto;
width:100%;
top:0px;
}
.menu
{
background:black;
color: white;
height: 100px;
}
.dynamiccontent
{
position:fixed;
top:50px;
margin:0px auto;
width:100%;
background: red;
}
.errorheader
{
color: white;
text-align: center;
font-size: 1.4em;
}
.errorcontent
{
color: white;
text-align: center;
}
.fixedtext
{
background: blue;
color: white;
position: relative;
}
.fillcontent
{
background: green;
position: relative;
overflow: auto;
z-index: 1;
height: 400px;
}
一个不错的选择是使用右侧的“浏览器滚动条”(不仅是绿色内容框中的短本地滚动条)。
谢谢您的帮助!