<!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%;
padding: 0;
margin: 0;
}
/* 方式一:position:absolute */
/* .outer {
position: relative;
height: 100%;
}
.A {
height: 100px;
background: red;
}
.B {
position: absolute;
top: 100px;
bottom: 0;
left: 0;
right: 0;
background: pink;
} */
/* 方式二: box-sizing:border-box */
/* .outer {
height: 100%;
box-sizing: border-box;
padding-top: 100px;
}
.A {
height: 100px;
margin-top: -100px;
background: red;
}
.B {
height: 100%;
background: pink;
} */
/* 方式三: */
.outer {
position: relative;
height: 100%;
box-sizing: border-box;
padding-top: 100px;
}
.A {
position: absolute;
height: 100px;
left: 0;
top: 0;
right: 0;
background: red;
}
.B {
height: 100%;
background: pink;
}
</style>
</head>
<body>
<!-- 有一个高度自适应的div,里面有两个div,一个高度100px,希望另一个填满剩下的高度。 -->
<div class="outer">
<div class="A"></div>
<div class="B"></div>
</div>
</body>
</html>