html头部底部固定高度中间大小自适应填充满屏幕css写法
第一种写法:使用display: flex
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
padding: 0;
margin: 0;
}
html,body,.box{
height: 100%;
}
.box{
display: flex;
flex-direction: column;
overflow: hidden;
}
.header{
height: 2rem;
width: 100%;
background-color: aqua;
}
.content{
height: 100%;
width: 100%;
background-color: rgb(255, 0, 119);
}
.footer{
height: 2rem;
width: 100%;
background-color: rgb(0, 255, 13);
}
</style>
</head>
<body>
<div class="box">
<div class="header"></div>
<div class="content"></div>
<div class="footer"></div>
</div>
</body>
</html>