fengchuanyu 2 недель назад
Родитель
Сommit
b3a13c2640
3 измененных файлов с 154 добавлено и 2 удалено
  1. 58 0
      2-CSS/20_层叠样式表.html
  2. 6 0
      2-CSS/复习/定位2.html
  3. 90 2
      2-CSS/练习12_定位练习.html

+ 58 - 0
2-CSS/20_层叠样式表.html

@@ -0,0 +1,58 @@
+<!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>
+        /* 多个选择器同时控制一个标签 样式会层叠 会把不同的属性进行合并 */
+
+
+        /* css优先级 权重值 */
+        /* 通配符选择器* < 标签选择器 < 类选择器 < id选择器 < 内联样式 */
+        /* .box{
+            font-size: 50px;
+            color: blue;
+        }
+
+         div{
+            color: red;
+            font-size: 100px;
+        }
+        #div1{
+            color: green;
+        } */
+        /* 通配符选择器 */
+        * {
+            /* !important 重要的 会将当前权重值提到最高 */
+            /* color: yellow !important; */
+        }
+
+         /* 选择器权重值可以累加 */
+         /* 通配符选择器* 0 < 标签选择器 1 < 类选择器 10 < id选择器 100 < 内联样式 1000 <!important 10000 */
+        .div1 .div2 {
+            color: blue;
+        }
+
+        div .div2 {
+            color: red;
+        }
+    </style>
+</head>
+
+<body>
+    <!-- 写在标签上的样式 内联样式 -->
+    <div class="box" id="div1" style="color: pink;">
+        hello world
+    </div>
+    <span>你好世界</span>
+
+    <div class="div1">
+        <div class="div2">
+            hello world
+        </div>
+    </div>
+</body>
+
+</html>

+ 6 - 0
2-CSS/复习/定位2.html

@@ -36,15 +36,21 @@
             width: 200px;
             height: 200px;
             /* float: left; */
+
+            opacity: 0.5;
         }
     </style>
 </head>
 
 <body>
     <!-- 文档流 -->
+
+    <!-- absolute fixed 元素脱离了文档流 他们旁边的元素会忽略特们 他们之前所占用的空间会被释放掉-->
+    <!-- relative 不会脱离文档流 -->
     <div class="box">
         <div class="div1"></div>
         <div class="div2"></div>
+        <span>hello world</span>
     </div>
 </body>
 

+ 90 - 2
2-CSS/练习12_定位练习.html

@@ -36,6 +36,82 @@
             color: #999;
             font-size: 12px;
         }
+        .content-bubble{
+            width: 500px;
+            height: 350px;
+            background-color: #b2dfdb;
+            margin:0 auto;
+            border-radius: 20px;
+            position: relative;
+        }
+        .bubble-item{
+            width: 100px;
+            height: 100px;
+            background-color: #81d4fa;
+            border-radius: 50%;
+            border:3px solid #fff;
+            position: absolute;
+            top:50%;
+            margin-top: -50px;
+            left:30px;
+            text-align: center;
+            line-height: 100px;
+        }
+        .bubble-item span{
+            color: #fff;
+        }
+        .bubble-item::after{
+            content: "";
+            display: block;
+            width: 30%;
+            height: 20%;
+            background-color: #fff;
+            position: absolute;
+            top:20%;
+            left: 20%;
+            border-radius: 50%;
+            opacity: 0.3;
+        }
+        .bubble-item:nth-child(2){
+            left: 23%;
+            top: 40%;
+            background-color: #ffd54f;
+            width: 80px;
+            height: 80px;
+            line-height: 80px;
+        }
+        .bubble-item:nth-child(3){
+            left: 53%;
+            top: 60%;
+            background-color: red;
+            width: 60px;
+            height: 60px;
+            line-height: 60px;
+            
+        }
+        .bubble-item:hover{
+            cursor: pointer;
+            z-index: 1;
+            /* 控制元素缩放 */
+            transform: scale(1.2);
+        }
+
+        /* .bubble-item:first-child:hover{
+            width: 108px;
+            height: 108px;
+
+        } */
+        .footer{
+            background-color: #fffde7;
+            color: #b28704;
+            /* 脱离文档流后的元素宽度跟内容撑开 */
+            position: fixed;
+            left: 0;
+            bottom: 0;
+            width: 100%;
+            text-align: center;
+
+        }
     </style>
 </head>
 <body>
@@ -46,9 +122,21 @@
                 <p class="info-center"><strong>任务:</strong> 观察并理解气泡的定位方式,鼠标悬停气泡试试看!</p>
                 <p class="info-bottom">(气泡用 absolute,气泡区用 relative,底部说明条用 fixed)</p>
             </div>
-            <div class="content-bubble"></div>
+            <div class="content-bubble">
+                <div class="bubble-item">
+                    <span>A</span>
+                </div>
+                <div class="bubble-item">
+                    <span>B</span>
+                </div>
+                <div class="bubble-item">
+                    <span>C</span>
+                </div>
+            </div>
+        </div>
+        <div class="footer">
+            <p>本页面用于练习 position: relative / absolute / fixed 及 hover/伪元素效果</p>
         </div>
-        <div class="footer"></div>
     </div>
 </body>
 </html>