fengchuanyu пре 1 месец
родитељ
комит
e9f73ef9bc
2 измењених фајлова са 173 додато и 0 уклоњено
  1. 33 0
      2_CSS/27_全屏大小元素.html
  2. 140 0
      2_CSS/练习10_定位气泡练习.html

+ 33 - 0
2_CSS/27_全屏大小元素.html

@@ -0,0 +1,33 @@
+<!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>
+        *{
+            margin: 0;
+        }
+        /* 块元素默认宽度为父元素宽度 */
+        /* 块元素宽度百分比的值是相较于父元素的宽度 */
+        /* 宽元素默认高度为内容高度 */
+        .box{
+            background-color: orange;
+            /* width: 100%;
+            height: 100%; */
+
+            /* 绝对定位如果所有父元素都没有定位,那么就以body为参考点 */
+            /* position: absolute; */
+            position: fixed;
+            top:0;
+            left: 0;
+            right: 0;
+            bottom: 0;
+        }
+    </style>
+</head>
+<body>
+    
+    <div class="box"></div>
+</body>
+</html>

+ 140 - 0
2_CSS/练习10_定位气泡练习.html

@@ -0,0 +1,140 @@
+<!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>
+        .bc{
+            position: fixed;
+            top:0;
+            left: 0;
+            right: 0;
+            bottom: 0;
+            background-color: #f0f4c3;
+        }
+        /*fixed absolute 定位之后的元素 之前的空间会被释放掉 默认宽度为内容宽度 */
+        .footer{
+            position: fixed;
+            bottom: 0;
+            left: 0;
+            z-index: 1;
+            background-color: #fffde7;
+            width: 100%;
+            height: 50px;
+            text-align: center;
+            line-height: 50px;
+            color: #b28704;
+        }
+        .content{
+            width: 500px;
+            background-color: #fff;
+            position: absolute;
+            z-index: 2;
+            left: 50%;
+            top:100px;
+            margin-left: -250px;
+            text-align: center;
+            padding:20px;
+            border-radius: 20px;
+        }
+        .content h1{
+            color: #689f38;
+        }
+        .content .info{
+            width: 300px;
+            margin: 10px auto;
+        }
+        .content .desc{
+            color: #999;
+            font-size: 12px;
+        }
+        .content .bubble-content{
+            background-color: #b2dfdb;
+            width: 500px;
+            height: 400px;
+            border-radius: 20px;
+            position: relative;
+        }
+        .content .bubble-content .bubble-one{
+            width: 50px;
+            height: 50px;
+            background-color: red;
+            border:3px solid #fff;
+            position: absolute;
+            left: 50%;
+            top: 50%;
+            margin-top: -25px;
+            margin-left: -25px;
+            border-radius: 50%;
+            color: white;
+            font-weight: bold;
+            line-height: 50px;
+        }
+        .content .bubble-content .bubble-two{
+            width: 80px;
+            height: 80px;
+            border:3px solid #fff;
+            background-color: #ffd54f;
+            border-radius: 50%;
+            color: #fff;
+            font-weight: bold;
+            line-height: 80px;
+            position: absolute;
+            top: 50px;
+            left: 50px;
+        }
+        .content .bubble-content .bubble-three{
+            width: 100px;
+            height: 100px;
+            border:3px solid #fff;
+            background-color: #81d4fa;
+            border-radius: 50%;
+            color: #fff;
+            font-weight: bold;
+            line-height: 100px;
+            position: absolute;
+            top: 80px;
+            left: 80px;
+        }
+        .content .bubble-content div::after{
+            content: "";
+            display: block;
+            width: 25%;
+            height: 20%;
+            background-color: rgba(255,255,255,0.5);
+            position: absolute;
+            top:20%;
+            left: 20%;
+            border-radius: 50%;
+            /* opacity: 0.5; */
+        }
+        .content .bubble-content div:hover{
+            padding: 20px;
+            margin-top: -20px;
+            margin-left: -20px;
+            z-index: 1;
+        }
+        .content .bubble-content .bubble-one:hover{
+            margin-left: -45px;
+            margin-top: -45px;
+        }
+    </style>
+</head>
+<body>
+    <div class="bc"></div>
+    <div class="content">
+        <h1>趣味气泡 Position 练习</h1>
+        <p class="info">任务: 观察并理解气泡的定位方式,鼠标悬停气泡试试看!</p>
+        <p class="desc">(气泡用 absolute,气泡区用 relative,底部说明条用 fixed)</p>
+        <div class="bubble-content">
+            <div class="bubble-one">A</div>
+            <div class="bubble-two">B</div>
+            <div class="bubble-three">C</div>
+        </div>
+    </div>
+    <div class="footer">
+        <span>本页面用于练习 position: relative / absolute / fixed 及 hover/伪元素效果</span>
+    </div>
+</body>
+</html>