|
@@ -0,0 +1,56 @@
|
|
|
+<!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>
|
|
|
+ /* BFC 区域 */
|
|
|
+ /* 生成BFC区域后 内不元素不会与外部元素关联 */
|
|
|
+ .box{
|
|
|
+ width: 400px;
|
|
|
+ height: 400px;
|
|
|
+ background-color: blue;
|
|
|
+ /* 开启 BFC */
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+ /* 内部元素的margin-top 超出父元素范围。(外边距溢出) */
|
|
|
+ .box2{
|
|
|
+ width: 200px;
|
|
|
+ height: 200px;
|
|
|
+ background-color: red;
|
|
|
+ margin-top: 100px;
|
|
|
+ /* margin-left: 100px; */
|
|
|
+ }
|
|
|
+
|
|
|
+ .box3,.box4{
|
|
|
+ width: 400px;
|
|
|
+ height: 400px;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 垂直外边距合并 */
|
|
|
+ .box3{
|
|
|
+ background-color: red;
|
|
|
+ margin-bottom: 50px;
|
|
|
+ }
|
|
|
+ .box4{
|
|
|
+ margin-top: 50px;
|
|
|
+ background-color: blue;
|
|
|
+ }
|
|
|
+ .box5{
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <!-- <div class="box">
|
|
|
+ <div class="box2"></div>
|
|
|
+ </div> -->
|
|
|
+ <div class="box5">
|
|
|
+ <div class="box3"></div>
|
|
|
+ </div>
|
|
|
+ <div class="box4"></div>
|
|
|
+
|
|
|
+
|
|
|
+</body>
|
|
|
+</html>
|