|
@@ -0,0 +1,68 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>BFC</title>
|
|
|
+ <style>
|
|
|
+ .box1,.box2{
|
|
|
+ height: 100px;
|
|
|
+ width: 100px;
|
|
|
+ float: left;
|
|
|
+ }
|
|
|
+ .box1{
|
|
|
+ background-color: red;
|
|
|
+ }
|
|
|
+ .box2{
|
|
|
+ background-color: blue;
|
|
|
+ }
|
|
|
+ .box3{
|
|
|
+ width: 300px;
|
|
|
+ height: 300px;
|
|
|
+ background-color: blue;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+ .box4{
|
|
|
+ width: 100px;
|
|
|
+ height: 100px;
|
|
|
+ background-color: red;
|
|
|
+ margin-top:50px;
|
|
|
+ }
|
|
|
+ .box5,.box6{
|
|
|
+ width: 100px;
|
|
|
+ height: 100px;
|
|
|
+ }
|
|
|
+ .box5{
|
|
|
+ background-color: blue;
|
|
|
+ margin-bottom: 50px;
|
|
|
+ }
|
|
|
+ .box6{
|
|
|
+ margin-top:30px;
|
|
|
+ background-color: red;
|
|
|
+ }
|
|
|
+ .box7{
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <a href="https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_display/Block_formatting_context">BFC文档</a>
|
|
|
+ <!-- BFC 块级格式化上下文 -->
|
|
|
+ <!-- 浮动后会出现父元素高度塌陷 -->
|
|
|
+ <!-- <div class="box">
|
|
|
+ <div class="box1"></div>
|
|
|
+ <div class="box2"></div>
|
|
|
+ <div>hello</div>
|
|
|
+ </div> -->
|
|
|
+ <!-- 外边距益出 -->
|
|
|
+ <!-- <div class="box3">
|
|
|
+ <div class="box4"></div>
|
|
|
+ </div> -->
|
|
|
+
|
|
|
+ <!-- 外边距合并 -->
|
|
|
+ <div class="box7">
|
|
|
+ <div class="box5"></div>
|
|
|
+ </div>
|
|
|
+ <div class="box6"></div>
|
|
|
+</body>
|
|
|
+</html>
|