fengchuanyu 1 vecka sedan
förälder
incheckning
b176298a73
3 ändrade filer med 104 tillägg och 0 borttagningar
  1. 39 0
      5_CSS3/1_位移.html
  2. 26 0
      5_CSS3/2_缩放.html
  3. 39 0
      5_CSS3/3_旋转.html

+ 39 - 0
5_CSS3/1_位移.html

@@ -0,0 +1,39 @@
+<!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{
+            width: 200px;
+            height: 200px;
+            background-color: red;
+            /* transform 变形 */
+            /* translate() 位移变换 有两个参数 第一个参数是水平方向的偏移量 第二个参数是垂直方向的偏移量 */
+            /* transform: translate(200px,100px); */
+            position: relative;
+        }
+        .div1{
+            width: 100px;
+            background-color: blue;
+            position: absolute;
+            top:50%;
+            left:50%;
+            /* 已知元素的宽度和高度 可以使用margin-top和margin-left来实现居中 */
+            /* margin-top: -50px;
+            margin-left: -50px; */
+            /* 未知元素的宽度和高度 可以使用transform: translate(-50%,-50%)来实现居中 */
+            /* translate 百分比相较于像素值 50% 表示元素的宽度的一半 50% 表示元素的高度的一半 */
+            transform: translate(-50%,-50%);
+        }
+    </style>
+</head>
+<body>
+    <div class="box">
+        <div class="div1">
+            <h1>hello world</h1>
+        </div>
+    </div>
+</body>
+</html>

+ 26 - 0
5_CSS3/2_缩放.html

@@ -0,0 +1,26 @@
+<!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{
+            width: 200px;
+            height: 200px;
+            background-color: red;
+            margin: 200px auto;
+            
+        }
+        .box:hover{
+            /* width: 300px;
+            height: 300px; */
+            /* scale() 缩放变换 有一个参数 用于指定缩放的比例 */
+            transform: scale(2);
+        }
+    </style>
+</head>
+<body>
+    <div class="box"></div>
+</body>
+</html>

+ 39 - 0
5_CSS3/3_旋转.html

@@ -0,0 +1,39 @@
+<!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{
+            width: 200px;
+            height: 200px;
+            background-color: red;
+            margin: 200px auto;
+            text-align: center;
+            line-height: 200px;
+            color: #fff;
+            font-size: 100px;
+            font-weight: bold;
+            /* rotate() 旋转变换 有一个参数 用于指定元素旋转的角度
+            正数顺时针旋转 负数逆时针旋转
+            */
+            /* transform: rotate(45deg); */
+            /* 原点 transform-origin 用于指定元素旋转的中心点 */
+            /* 默认值是元素的中心点 */
+            /* transform-origin有两个值 分别是水平方向和垂直方向的原点 */
+            /* 可以使用 top left right bottom 也可以使用百分比 、像素值 */
+            /* 原点可以在元素外部 */
+            transform-origin: center 500px;
+
+            transform: rotate(45deg);
+        }
+    </style>
+</head>
+<body>
+    <div class="box">
+        中
+    </div>
+
+</body>
+</html>