fengchuanyu 1 tuần trước cách đây
mục cha
commit
b8e8b2ffb9
2 tập tin đã thay đổi với 80 bổ sung0 xóa
  1. 2 0
      5-CSS3/练习1_旋转照片.html
  2. 78 0
      5-CSS3/练习2_时钟.html

+ 2 - 0
5-CSS3/练习1_旋转照片.html

@@ -13,6 +13,8 @@
         }
         .box img{
             width: 400px;
+            transition: all 1s linear;
+
         }
         .box img:first-child{
             transform: rotate(45deg) ;

+ 78 - 0
5-CSS3/练习2_时钟.html

@@ -0,0 +1,78 @@
+<!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 reset */
+        *{
+            margin: 0;
+            padding: 0;
+        }
+        li{
+            list-style: none;
+        }
+
+
+        .box{
+            width: 400px;
+            height: 400px;
+            border:2px dashed black;
+            margin:100px auto;
+        }
+        .clock{
+            width: 400px;
+            height: 400px;
+            border-radius: 50%;
+            border:2px solid black;
+            box-sizing: border-box;
+            position: relative;
+        }
+
+        .clock ul li{
+            width: 4px;
+            height: 6px;
+            background-color: black;
+            position: absolute;
+            top:0;
+            left: 50%;
+            margin-left: -2px;
+            transform-origin: center 198px;
+        }
+        .clock ul li:nth-child(5n+1){
+            height: 12px;
+        }
+
+        /* .clock ul li:nth-child(2){
+            transform: rotate(6deg);
+        }
+        .clock ul li:nth-child(3){
+            transform: rotate(12deg);
+        } */
+    </style>
+</head>
+<body>
+    <div class="box">
+        <div class="clock">
+            <ul id="clock-item">
+                
+            </ul>
+        </div>
+    </div>
+    <script>
+        // 获取刻度容器
+        var clickItem = document.getElementById("clock-item");
+
+        // 生成刻度
+        for(var i=0;i<60;i++){
+            // 创建li
+            var oLi = document.createElement("li");
+            // 为每一个li添加角度
+            oLi.style.transform = "rotate("+(i*6)+"deg)";
+            // 将创建好的li插入容器中
+            clickItem.appendChild(oLi);
+        }
+    </script>
+</body>
+</html>