Blogger Information
Blog 16
fans 1
comment 0
visits 14166
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
2019年7月5日作业(一) - 外边距的三个特征: 同级塌陷,嵌套传递,自动挤压
杜强_上海_315106编程学习
Original
1000 people have browsed it

以下代码为外边距的三个特征: 同级塌陷,嵌套传递,自动挤压

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="static/css/style3.css">
    <title>外边距的三个特征</title>
</head>
<body>
<h3>同级塌陷</h3>
<div class="box1"></div>
<div class="box2"></div>

<h3>嵌套传递</h3>
<div class="box3">
    <div class="box4"></div>
</div>

<h3>自动挤压</h3>
<div class="box5"></div>
<div class="box6"></div>


</body>
</html>
.box1 {
    width: 200px;
    height: 200px;
    background-color: blue;
}

.box2 {
    width:200px;
    height:200px;
    background-color: red;
}

.box1 {
    margin-bottom: 30px;
}

.box2 {
    margin-top: 60px;
}

.box3 {
    width: 200px;
    height: 200px;
    background-color: blue;
}

.box4 {
    width:100px;
    height:100px;
    background-color: red;
}
.box4 {
    margin-top: 0;
}
.box3 {
    padding-top: 50px;
    height: 150px;
}

.box5 {
    width: 200px;
    height: 200px;
    background-color: blue;
}
.box {
    margin: auto;
}

.box6 {
    width:200px;
    height:200px;
    background-color: red;
}
.box5 {
    margin: auto;
}
.box6 {
    margin: 50px auto;
}

以上代码执行结果截图:

0705-1.png

总结:理解外边距的三个特征: 同级塌陷,嵌套传递,自动挤压!应注意以下几点:

  1. 嵌套传递尽量少用或者不用

  2. 自动挤压的写法

  3. 同级塌陷的理解


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post