| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <!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>
- .box1{
- width: 400px;
- height: 400px;
- background-color: blue;
- /* float: left; */
- overflow: hidden;
- /* display: inline-block */
- /* border:1px solid black; */
- }
- .box2{
- width: 200px;
- height: 200px;
- background-color: red;
- margin-top: 100px;
- margin-left: 100px;
- }
- .box3,.box4{
- width: 200px;
- height: 200px;
- }
- .box3{
- background-color: green;
- margin-bottom: 20px;
- }
- .box4{
- margin-top: 30px;
- background-color: yellow;
- }
- .box5{
- overflow: hidden;
- }
- </style>
- </head>
- <body>
- <!-- 外边距溢出 仅限于垂直方向 margin-top-->
- <!-- BFC 块格式化上下文-->
- <!-- BFC 限制内部元素与外部元素接触 内部元素所有效果仅限于BFC区域内 -->
- <div class="box1">
- <div class="box2"></div>
- </div>
- <!-- 外边距合并 上下两个相邻元素 垂直方向 margin-top margin-bottom 合并成一个 -->
- <div class="box5">
- <div class="box3"></div>
- </div>
- <div class="box4"></div>
- </body>
- </html>
|