天天看点

头尾固定-中间部分可滚动-布局

头尾固定-中间部分可滚动-布局:

<!DOCTYPE html>
 <style>
   *{
       margin: 0;
       padding: 0;
   }
   body{
       display: flex;
       flex-direction: column;
       height: 100vh;
   }
   #top{
       height: 50px;
       background: red;
   }
   #center{
       flex: 1;
       height: 100%;
       overflow-y:auto;
   }
   .center{
       height: 200vh;
       background: pink;
   }
   #bottom{
       height: 50px;
       background: green;
   }
 </style>
<body>
	<div id="top">头部</div>
	<div id="center">
    	<div class="center">中间</div>
	</div>
	<div id="bottom">底部</div>
</body>