1020人加入学习
(2人评价)
Web前端第二季(CSS)

制作完成于2018年6月6日 CSS2.0,

价格 免费
<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <title>外边距自动合并</title>
    <style type="text/css">
        .one,.two{
            width:300px;
            height:300px;
        }
        .one{
            background-color: red;
            margin-bottom:30px;
        }
        .two{
            background-color: green;
            margin-top:20px;
        }
    </style>
</head>
<body>
    <div class="one"></div>
    <div class="two"></div>
</body>
</html>

上下元素的外边距,采用了更大的30px。红绿色块之间的间隔是30px。

合并外边框,变大,采取最大的那个。

<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <title>外边距自动合并</title>
    <style type="text/css">
        .one{
            width:300px;
            height:300px;
        }
        .two{
            width:100px;
            height:100px;
        }
        .one{
            background-color: red;
            margin-top:30px;
        }
        .two{
            background-color: green;
            margin-top:50px;
        }
    </style>
</head>
<body>
    <div class="one">
        <div class="two"></div>
    </div>
</body>
</html>

都是距离顶部的外边距,采取更大的外边距。so距离顶部是50px

[展开全文]

自动选取重叠外边距最大的

[展开全文]

授课教师

SiKi学院老师

课程特色

下载资料(1)
视频(47)