<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>定位</title>
<style>
.test1 {
display: flex;
flex-direction: column;
width: 200px;
height: 300px;
background-color: blanchedalmond;
border-radius: 6px;
}
.test1 .top {
height: 180px;
background-color:darkkhaki;
}
.test1 .bottom{
flex: 1;
background-color: cadetblue;
}
</style>
</head>
<body>
<div class="test1">
<div class="top"></div>
<div class="bottom"></div>
</div>
</body>
</html>
效果如下:
可以看到,父div沒有圓角邊框。
是因為,子div的背景顏色內容溢出了。
解決方案:父div添加overflow:hidden。