e před 11 měsíci
rodič
revize
2c64d9763e
3 změnil soubory, kde provedl 118 přidání a 0 odebrání
  1. 0 0
      css/10.padding和margin.html
  2. 49 0
      css/11.浮动.html
  3. 69 0
      css/12.清除浮动.html

+ 0 - 0
css/9.padding和margin.html → css/10.padding和margin.html


+ 49 - 0
css/11.浮动.html

@@ -0,0 +1,49 @@
+<!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: 200px;
+            height: 200px;
+            /* float: left; */
+            /* display: inline-block; */
+            background: #f00;
+        }
+        #box2 {
+            width: 200px;
+            height: 200px;
+            float: left;
+            /* display: inline-block; */
+            background: #ff0;
+        }
+        #box3 {
+            width: 200px;
+            height: 200px;
+            float: left;
+            /* display: inline-block; */
+            background: #f0f;
+        }
+        #box4 {
+            width: 200px;
+            height: 200px;
+            background: #0f0;
+        }
+    </style>
+</head>
+<body>
+    <!-- 
+        浮动:使元素在一行排列
+        float 浮动
+        left 左浮
+        right 右浮
+        脱离文档流
+     -->
+     <div id="box1">1</div>
+     <div id="box2">2</div>
+     <div id="box3">3</div>
+     <div id="box4">4</div>
+</body>
+</html>

+ 69 - 0
css/12.清除浮动.html

@@ -0,0 +1,69 @@
+<!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>
+      /* .main {
+        overflow: auto;
+    } */
+      #box1 {
+        width: 200px;
+        height: 200px;
+        float: left;
+        background-color: aqua;
+      }
+      #box2 {
+        width: 200px;
+        height: 200px;
+        float: left;
+        background-color: rgb(106, 0, 255);
+      }
+      #box3 {
+        width: 200px;
+        height: 200px;
+        float: left;
+        background-color: rgb(255, 111, 0);
+      }
+      #box4 {
+        width: 200px;
+        height: 200px;
+        float: left;
+        background-color: rgb(255, 0, 98);
+      }
+      /* #box5 {
+        clear: both;
+      } */
+      .clearfix::after {
+        content: "";
+        display: block;
+        clear: both;
+      }
+    </style>
+  </head>
+  <body>
+    <!-- 
+        浮动会导致父元素高度塌陷
+        清除浮动办法:
+        1.溢出隐藏法
+            在父元素上添加overflow:hidden/auto
+        2.额外标签法:
+            在使用浮动的子集同级添加一个空标签 并给标签添加clear:both/left/right 属性
+        3.伪元素清浮动
+           在style中添加 .clearfix::after {
+                content: "";
+                display: block;
+                clear: both;
+            }
+            将clearfix添加到高度塌陷的父元素上
+     -->
+    <div class="main clearfix">
+      <div id="box1">1</div>
+      <div id="box2">2</div>
+      <div id="box3">3</div>
+      <div id="box4">4</div>
+      <!-- <div id="box5"></div> -->
+    </div>
+  </body>
+</html>