e hai 1 ano
pai
achega
e2dd5d024d
Modificáronse 1 ficheiros con 18 adicións e 0 borrados
  1. 18 0
      html/day6/定位.html

+ 18 - 0
html/day6/定位.html

@@ -5,6 +5,13 @@
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>Document</title>
     <style>
+        .box {
+            width: 400px;
+            height: auto;
+            border: 4px solid #f00;
+            margin-left: 300px;
+            /* position: relative; */
+        }
         .box div {
             width: 200px;
             height: 200px;
@@ -24,6 +31,13 @@
             position: fixed;
             bottom: 100px;
             left:100px;
+            background: orange;
+            /* position: relative;
+            top: 100px;
+            left: 300px; */
+            /* position: absolute;
+            top: 300px;
+            left: 20px; */
         }
     </style>
 </head>
@@ -39,6 +53,10 @@
             1.sticky 粘性定位 吸顶效果 top 一起使用 不脱离文档流 占位
             2.static 静态定位 不对页面产生影响
             3.fixed  固定定位 脱离文档流 不占位 相对于祖先元素定位
+            4.relative 相对定位 不脱离文档流 占位 相对于自己本身去定位 
+            5.absolute 绝对定位 脱离文档流 不占位
+                a.相对于祖先元素进行定位  当父级没有定位时
+                b.父级存在定位 (相对定位) absolute就是相对于父级进行定位
      -->
     <div class="box">
         <div class="one">1</div>