我正在尝试创建一个包含头部、主内容区和页脚的布局。
头部和页脚高度固定,但内容区需要填充宽度和高度(无滚动条)。
当前代码在这里。
<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位置或清除方面做错了什么,但我找不到问题所在。
我该如何修复它?有更好的方法来完成这种布局吗?