使用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>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章