第一种方式:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
html,body{
height: 100%;
width: 100%;
}
body{
margin: 0;
display: flex;
flex-direction: column;
}
.title{
width: 100%;
height: 50px;
background-color: pink;
}
.content {
flex: 1;
overflow-y: auto;
}
.box {
width: 300px;
height: 200px;
background-color: blue;
margin-top: 10px;
}
.bottom{
width: 100%;
height: 50px;
background-color: greenyellow;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="title">
</div>
<div class="content">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
<div class="bottom">
</div>
</body>
</html>
第二种实现方式:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.title{
width: 100%;
height: 100px;
background-color: red;
position: fixed;
left: 0;
top: 0;
}
.content{
padding-top: 100px;
padding-bottom: 55px;
}
.box{
width: 300px;
height: 300px;
background-color: plum;
margin-top: 10px;
}
.bottom{
width: 100%;
height: 55px;
position: fixed;
bottom: 0;
left: 0;
background-color: rosybrown;
}
</style>
</head>
<body>
<div class="title">
</div>
<div class="content">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
<div class="bottom">
</div>
</body>
</html>