fengchuanyu 17 ore fa
parent
commit
0398af91c2
1 ha cambiato i file con 73 aggiunte e 0 eliminazioni
  1. 73 0
      5_CSS3/练习1_时钟.html

+ 73 - 0
5_CSS3/练习1_时钟.html

@@ -0,0 +1,73 @@
+<!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;
+            padding: 0;
+        }
+        li{
+            list-style: none;
+        }
+        .box{
+            width: 404px;
+            height: 404px;
+            border: 2px dashed black;
+            position: fixed;
+            top: 50%;
+            left: 50%;
+            transform: translate(-50%,-50%);
+        }
+        .clock{
+            width: 400px;
+            height: 400px;
+            border: 2px solid black;
+            border-radius: 50%;
+            position: relative;
+        }
+        .clock li{
+            width: 2px;
+            height: 6px;
+            background-color: black;
+            position: absolute;
+            top: 0;
+            left: 50%;
+            /* transform: translateX(-50%); */
+            margin-left: -1px;
+            transform-origin: center 200px;
+
+        }
+        /* .clock li:nth-child(1){
+            transform: rotate(6deg) translateX(-50%);
+        }
+        .clock li:nth-child(2){
+            transform: rotate(12deg) translateX(-50%);;
+        } */
+        .clock li:nth-child(5n+1){
+            height: 12px;
+        } 
+    </style>
+</head>
+<body>
+    <div class="box">
+        <div class="clock">
+            <ul>
+                <!-- <li></li>
+                <li></li>
+                <li></li> -->
+            </ul>
+        </div>
+    </div>
+    <script>
+        var oUl = document.getElementsByTagName("ul")[0];
+        var str = ""
+        for(var i=0;i<60;i++){
+          str += "<li style='transform: rotate("+(i*6)+"deg);'></li>"  
+        }
+        oUl.innerHTML = str;
+    </script>
+</body>
+</html>