【发布时间】:2020-07-09 09:09:02
【问题描述】:
我有 html 页面,容器 div 包含页眉、内容和页脚 div,html cod 和 css 代码是这样的:
HTML 代码:
<html>
<div class="container">
<div class="header"></div>
<div class="content">
<div class="content2"></div>
</div>
<div class="footer"></div>
</div>
</html>
CSS代码:
header{
padding-bottom:5px;
width:100%;
position:fixed;
top:0;
z-index:100;
height:70px;
background-color:#006}
.content{
min-height: 100%;
width:100%;
background-color:#006;
margin-top:70px;
margin-bottom:60px }
.content2{
margin:auto;
min-height: 100%;
width:95%;
background-color:#FFFEA5;
padding-bottom: 20px;
}
.footer{
text-align:center;
width:100%;
position:fixed;
bottom:0;
z-index:100;
height:70px;
background-color:#006}
我希望 content2 div 是全屏的,或者它不包含任何内容,我做了上面的代码但没有用,它看起来像附加的图像。
【问题讨论】:
-
你能告诉我们不同的
div元素会包含什么,以便更容易看出哪个div影响了高度吗? -
@TylerHarrison Sir 如图所示。内容 div 不是全屏的,我想在页眉和页脚之间填充
-
可能是
margin-bottom: //whatever minus amout,因为获取间隙的高度并做一个负边距,然后padding-bottom: //whatever amout来填补那个间隙。 -
你想让
div.content2覆盖整个屏幕吗?试试height:100vh
标签: html css fullscreen