使用CSS3布局:header和footer固定在上下两端,中间body自适应上下伸展,超过一页时中间body内容上下滑动

 

<body>
    <header class="header">header高度固定86px</header>
    <section class="mainBox">
      <div class="leftBox">左侧自适应上下铺满</div> 
      <div class="rightBox">右侧自适应上下铺满,内容过量时右侧上下滚动即可
        <li v-for="item in 70">测试-----往下滑</li>
      </div>
      
    </section>
    <footer class="footer">@ footer固定高度40px</footer>
</body>
<style>
* {
  margin: 0;
  padding: 0;
}
.header {
  width: 100%;
  height: 60px;
  position: absolute;
  top: 0;
  /*以上设置是重点必须的*/
  background: rgb(30, 75, 69);
  padding-left:50px;
  color: #fff;
  font-size:20px;
  line-height: 80px;
}

.footer {
  width: 100%;
  height: 60px;
  background: rgb(30, 75, 69);
  color: #fff;
  position: absolute;
  bottom: 0;
  /*以上设置是重点必须的*/
  text-align: center;
  line-height: 40px;
}
.mainBox {
  width: 100%;
  position: absolute;
  top: 60px;
  bottom: 60px;
  /*以上设置是重点必须的*/
  border:3px solid blue;
}
.mainBox .leftBox {
  height: 100%;
  width: 200px;
  float: left;
  margin-bottom: 40px;
  overflow: auto;
  /*以上设置是重点必须的*/
  border: 2px solid green;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  text-align: center;
  line-height: 40px;
}
.mainBox .rightBox {
  height: 100%;
  margin-left: 0;
  /*以上设置是重点必须的*/
  border: 2px solid crimson;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  overflow: auto;
  text-align: left;
  line-height: 40px;
}
</style>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值