e 1 жил өмнө
parent
commit
25368633d7

+ 46 - 0
day4/8.浮动.html

@@ -0,0 +1,46 @@
+<!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>
+         .one,.two,.three {
+            width: 200px;
+            height: 200px;
+            /* display: inline-block; */
+         }
+         .one {
+            float: left;
+            background: #00f;
+         }
+         .two {
+            width: 300px;
+            float: left;
+            background: #f00;
+         }
+         .three {
+            float: left;
+            background: #ff0;
+         }
+    </style>
+</head>
+<body>
+    <!-- 
+        页面的组成:
+            文档流 标准流
+            浮动
+        为什么要使用浮动?
+         因为要让内容在一行展示
+         float:left/right/none
+        浮动会导致元素脱离文档流 不占位
+        浮动 对浮动前的元素无影响 只对浮动后的元素有影响
+        缺点:会导致父元素盒子高度塌陷
+     -->
+    <div class="main">
+        <div class="one"></div>
+        <div class="two"></div>
+        <div class="three"></div>
+    </div>
+</body>
+</html>

+ 68 - 0
day4/9.清浮动方法.html

@@ -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>Document</title>
+    <style>
+        .main {
+            /* overflow: auto; */
+        }
+         .one,.two,.three {
+            width: 200px;
+            height: 200px;
+            /* display: inline-block; */
+         }
+         .one {
+            float: left;
+            background: #00f;
+            color: #fff;
+         }
+         .two {
+            width: 300px;
+            float: left;
+            background: #f00;
+         }
+         .three {
+            float: left;
+            background: #ff0;
+         }
+         .four {
+            clear: right;
+         }
+         #clearfix::after {
+            content: "";
+            display: block;
+            clear: both;
+         }
+    </style>
+</head>
+<body>
+    <!-- 
+        清浮动方法:
+            1.溢出隐藏法:
+                在浮动的父级盒子上添加overflow:hidden(隐藏)||auto(自适应)
+            2.额外标签法 
+                在浮动的同级创建一个空标签,并添加属性clear:both|left|right|none
+            3.伪元素清浮动
+                .clearfix::after {
+                    content: "";
+                    display: block;
+                    clear: both;
+                }
+            将属性名添加到浮动的父级盒子上
+
+            特殊符号
+            &nbsp; 半格
+            &lt; 小于号
+            &gt; 大于号
+            &reg; 商标
+     -->
+    <div class="main" id="clearfix">
+        <div class="one">&reg;</div>
+        <div class="two"></div>
+        <div class="three"></div>
+        <!-- <div class="four"></div> -->
+    </div>
+</body>
+</html>