fengchuanyu 1 月之前
父節點
當前提交
18f8cae0b2
共有 3 個文件被更改,包括 83 次插入2 次删除
  1. 11 2
      2_CSS/23_透明.html
  2. 19 0
      2_CSS/24_rgb.html
  3. 53 0
      2_CSS/25_定位.html

+ 11 - 2
2_CSS/23_透明.html

@@ -19,10 +19,19 @@
             height: 400px;
             background-color: blue;
         }
+        .box3{
+            width: 300px;
+            height: 300px;
+            background-color: rgba(0,255,0,0.1);
+            /* opacity: 0.5; */
+        }
     </style>
 </head>
 <body>
-    <div class="box1">hello world</div>
-    <div class="box2"></div>
+    <!-- <div class="box1">hello world</div>
+    <div class="box2"></div> -->
+
+    <div class="box3">hello world</div>
+
 </body>
 </html>

+ 19 - 0
2_CSS/24_rgb.html

@@ -0,0 +1,19 @@
+<!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>
+        .box{
+            /* rgb格式的颜色 红色 绿色 蓝色 0-255取值 */
+            /* color: rgb(255,0,0); */
+            /* rgba格式的颜色 红色 绿色 蓝色 透明度 0-1取值 */
+            color: rgba(255,0,0,0.5);
+        }
+    </style>
+</head>
+<body>
+    <div class="box">hello world</div>
+</body>
+</html>

+ 53 - 0
2_CSS/25_定位.html

@@ -0,0 +1,53 @@
+<!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>
+        .box1{
+            width: 400px;
+            height: 400px;
+            border:3px dashed red;
+            position: relative;
+        }
+        .box2{
+            width: 200px;
+            height: 200px;
+            background-color: blue;
+            /* margin-top: 50px; */
+            /* 相对定位  元素相对于其原来的位置进行定位 */
+            /* 定位之后 可以使用四个方向属性  top bottom left right */
+            position: relative;
+            top:50px;
+        }
+        .box3{
+            width: 100px;
+            height: 100px;
+            background-color: green;
+        }
+        span{
+            background-color: yellow;
+            /* 绝对定位  元素相对于其最近的定位祖先元素进行定位 */
+            /* 满足两个条件 1 必须是祖先元素 2这个祖先元素必须定位(不能使用static) */
+            position: absolute;
+            /* right: 0;
+            bottom: 0; */
+            /* 50% 表示距离顶部50% 相较于父元素的高度 */
+            top: 50%;
+
+            /* 50% 表示距离左侧50% 相较于父元素的宽度 */
+            left: 50%;
+            /* margin 使用负数的时候 可以将元素向相反方向移动 */
+            margin-top: -20px;
+        }
+    </style>
+</head>
+<body>
+    <div class="box1">
+        <div class="box2"></div>
+        <div class="box3"></div>
+        <span>这是一个span标签</span>
+    </div>
+</body>
+</html>