【发布时间】:2021-02-28 11:19:46
【问题描述】:
我正在尝试创建一个带有页眉、主要内容区域和页脚的布局。
页眉和页脚都是固定高度,但内容区域需要填充宽度和高度(没有滚动条)
当前代码是here
<div class="outer">
<header>
movistar ovacion
</header>
<div id="content" >
<section class="step-1">
<div class="box">
<a href="#">HOMBRE</a>
</div>
<div class="box">
<a href="#">MUJER</a>
</div>
<div class="box">
<a href="#">NIÑO</a>
</div>
<div class="box">
<a href="#">NIÑA</a>
</div>
</section>
</div>
<footer>
footer
</footer>
</div>
CSS:
html,body{
height: 100%;
}
header {
height: 160px;
background: blue;
}
#content {
}
footer {
height: 60px;
position:absolute;
width:100%;
bottom:0;
background: green;
}
.outer {
}
.step-1 > div {
width: 50%;
height: 50%;
position: absolute;
}
.step-1 > div:first-child {
background: #DDD;
left: 0;
}
.step-1 > div:nth-child(2) {
background: #CCC;
right: 0;
}
.step-1 > div:nth-child(3) {
background: #72CCA7;
left: 0;
bottom: 0;
}
.step-1 > div:nth-child(4) {
background: #10A296;
right: 0;
bottom: 0;
}
现在内容区域不能正常工作,4 个框不适应高度。
我认为我在 div 位置或清除方面做错了,但我找不到问题。
我该如何解决?有没有更好的方法来做这个布局?
【问题讨论】: