<!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>
.father {
height: 500px;
width: 600px;
background-color: aqua;
overflow-y: auto;
}
.son {
height: 520px;
width: 50%;
background-color: brown;
}
</style>
</head>
<body>
<div class="father">
<div class="son"></div>
</div>
</body>
</html>
不要被颜色蒙蔽了双眼,父盒子还是那么高,还都是aqua色 子盒子也是那么高也是那个色
神奇的overflow属性(鱼与熊掌不可兼得,但是他却兼得了,牛逼儿)
很明显子盒子高度高出了父盒子,父盒子高度是500 显示是aqua色。