e vor 1 Jahr
Ursprung
Commit
2184b1b0b3
3 geänderte Dateien mit 126 neuen und 0 gelöschten Zeilen
  1. 1 0
      day3/html/6.选择器优先级.html
  2. 77 0
      day5/定位.css
  3. 48 0
      day5/定位.html

+ 1 - 0
day3/html/6.选择器优先级.html

@@ -21,6 +21,7 @@
      <!-- 
         HTML为什么语义化?
         1.便携开发
+        2.方便搜索引擎(SEO)抓取数据
       -->
 </body>
 </html>

+ 77 - 0
day5/定位.css

@@ -0,0 +1,77 @@
+* {
+    /* margin: 0;
+    padding: 0; */
+    box-sizing: border-box;
+}
+
+
+div {
+    width: 200px;
+    height: 200px;
+    font-size: 30px;
+    font-weight: bold;
+    color: #fff;
+}
+
+.box1 {
+    margin-top: 15px;
+    background: #0f0;
+}
+.box2 {
+    margin-top: 15px;
+    background: #0ff;
+    /* position: fixed; */
+    /* top: 215px; */
+    /* left: 400px; */
+}
+.box3 {
+    margin-top: 15px;
+    background: #ff0;
+    /* position: sticky;
+    top: 40px; */
+}
+.box4 {
+    margin-top: 15px;
+    background: #f00;
+    /* position: static; */
+    /* position: relative;
+    left: 100px;
+    top: 100px; */
+    position: absolute;
+    top: 100px;
+    z-index:3;
+}
+.box5 {
+    margin-top: 15px;
+    background: pink;
+    /* position: relative; */
+
+}
+.box6 {
+    margin-top: 15px;
+    background: #00f;
+}
+.box7 {
+    margin-top: 15px;
+    background: orange;
+}
+.box8 {
+    margin-top: 15px;
+    background: orange;
+}
+.box9 {
+    margin-top: 15px;
+    background: orange;
+    position: absolute;
+    top: 100px;
+    z-index: 99;
+}
+
+#box {
+    width: 800px;
+    height: 100%;
+    border: 2px solid #00f;
+    position: relative;
+    margin-top: 300px;
+    background-color: rgb(215, 37, 255);
+}

+ 48 - 0
day5/定位.html

@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+    <link rel="stylesheet" href="./定位.css">
+</head>
+<body>
+    <!-- 
+        一个完整的网页:
+        文档流(标准流)
+        浮动
+        定位
+
+
+        定位:
+            position:
+            1.fixed 
+                相对于浏览器的视口定位
+                固定定位 脱离文档流 不占位
+            2.sticky
+                粘性定位 搭配top一起使用 一般用于吸顶效果
+            3.static
+                静态定位 页面存在即存在 不对页面造成影响
+            4.relative 
+                相对定位 不脱离文档流占位 相对于自己本身
+            5.absolute 
+                绝对定位:
+                a.父级元素没有任何定位的时候 相对于祖先元素定位 脱离文档流不占位
+                b.父级存在定位:相对定位;子绝父相 子级相对于父级定位  脱离文档流不占位
+            控制层级:z-index
+        搭配:top bottom right left
+     -->
+    <div id="box">
+        <div class="box1">1</div>
+        <div class="box2">2</div>
+        <div class="box3">3</div>
+        <div class="box4">4</div>
+        <div class="box5">5</div>
+        <div class="box6">6</div>
+        <div class="box7">7</div>
+        <div class="box8">8</div>
+        <div class="box9">9</div>
+
+    </div>
+</body>
+</html>