网上看了一大堆别人的方法 要么就是根本无法完成效果 要么就是右边会出现滚动条 终于找到一个能用的方法
1.flex布局 利用纵向flex 布局 中间自动填充 但设置外部最小高度100vh;可完全实现效果
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
html, body{
height: 100% ;
margin: 0;
padding: 0 ;
}
.container {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.content {
flex: 1;
}
.footer {
height: 60px;
background-color: blue;
}
</style>
</head>
<body>
<div>
<div class="container">
<div class="content">内容</div>
<div class="footer">页脚</div>
</div>
</div>
</body>