嵌套元素坍塌

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #dv1 {
            width: 200px;
            height: 200px;
            background-color: #16a085;
        }

        #dv2 {
            width: 100px;
            height: 100px;
            background-color: #e67e22;
            /* 1.可以为父元素定义上边框
            2.可以为父元素定义上内边距
            3.可以为父元素添加overflow:hidden */
            margin-top: 50px;
        }
    </style>
</head>

<body>
    <div id="dv1">
        <div id="dv2"></div>
    </div>
</body>

</html>
posted @ 2021-04-23 22:16  yongerbingxuan  阅读(53)  评论(0)    收藏  举报