fengchuanyu 3 months ago
parent
commit
28a0dc6249
2 changed files with 57 additions and 4 deletions
  1. 4 4
      8_CSS3/5_CSS3缩放.html
  2. 53 0
      8_CSS3/6_CSS33D效果.html

+ 4 - 4
8_CSS3/5_CSS3缩放.html

@@ -11,7 +11,8 @@
             background-color: red;
             transition: all 1s;
             position: absolute;
-           
+            top:100px;
+            left: 100px;
         }
         body{
             width: 100vw;
@@ -20,9 +21,8 @@
         }
         body:hover .box{
             transform:scale(3);
-            position: absolute;
-            right: 0;
-            bottom: 0;
+            top: 400px;
+            left: 400px;
         }
     </style>
 </head>

+ 53 - 0
8_CSS3/6_CSS33D效果.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>
+        body{
+            /* 设置观众视角 */
+            /* 视角的距离 */
+            perspective: 1000px;
+            /* 视角的位置 */
+            perspective-origin: center center;
+        }
+        .box,.div1,.div2{
+            width: 200px;
+            height: 200px;
+        }
+        .box{
+            border:1px dashed black;
+            position: relative;
+            margin: 100px auto;
+            /* 使其内部元素的变形为3D效果 */
+            transform-style: preserve-3d;
+
+        }
+        .div1,.div2{
+            position: absolute;
+            top: 0;
+            left: 0;
+            transition: all 3s;
+        }
+        .div1{
+            background-color: red;
+        }
+        .div2{
+            background-color: blue;
+        }
+        .box:hover .div2{
+            transform: rotateY(180deg) translateZ(20px);
+        }
+        .box:hover .div1{
+            transform: rotateY(180deg) translateZ(1px);
+        }
+    </style>
+</head>
+<body>
+    <div class="box">
+        <div class="div1"></div>
+        <div class="div2"></div>
+    </div>
+</body>
+</html>