代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body, html {
box-sizing: border-box;
margin: 0;
padding: 0;
height: 100%;
}
.font-style {
font-size: 20px;
font-weight: bold;
}
.header, .footer {
height: 50px;
background: #2b542c;
}
.cont {
background: #1b6d85;
}
.vertical-scroll-layout {
display: flex;
flex-direction: column;
height: 100%;
box-sizing: border-box;
}
.cont-scroll-wrap {
flex: auto;
height: 0;
overflow-y: auto;
}
</style>
</head>
<body>
<div class="vertical-scroll-layout">
<div class="header font-style">header</div>
<div class="cont-scroll-wrap cont">
<div class="font-style" style="height: 2000px;width: 400px;background: linear-gradient(blue, red)">
cont
</div>
</div>
<div class="footer font-style">footer</div>
</div>
<script>
</script>
</body>
</html>
示例
![在这里插入图片描述](https://img-blog.csdnimg.cn/11465996e8964d95851c29769fa7c1c0.gif#pic_center)