css设置div高度自动填满

2020-5-3 zhulinan CSS样式表

<!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>css设置div高度自动填满</title>
<style>
*{
  margin: 0 auto;
  padding: 0;
}
html, body{
  width: 100%;
  height: 100%;
}
.frame{
  text-align: center;
  width: 100%;
  min-height: 100%;
}
.frame .head{
  width: 100%;
  height: 40px;
  position: fixed;
  top: 0;
  background: #fff;
}
.frame .content{
  width: 100%;
  line-height: 60px;
  position: fixed;
  top: 40px;
  bottom: 30px;
  background: #336699;
  overflow: auto;
}
.frame .foot{
  width: 100%;
  height: 30px;
  position: fixed;
  bottom: 0;
  background: green;
}
</style>
</head>
<body>
<div class='frame'>
  <div class='head'>head</div>
  <div class='content'>高度自适应区域<br />1<br />2<br />3<br />4<br />5<br />6<br />7</div>
  <div class='foot'>foot</div>
</div>
</body>

</html>


网站备案号:京ICP备11043289号-1 北京市公安局网络备案 海1101084571
版权所有 北京育灵童科技发展有限公司 Copyright © 2002-2024 www.elight.cn, All Rights Reserved