fengchuanyu 8 ay önce
ebeveyn
işleme
62876c7766

BIN
6_css3/img/a.jpg


BIN
6_css3/img/b.jpg


BIN
6_css3/img/c.jpg


BIN
6_css3/img/d.jpg


BIN
6_css3/img/e.jpg


BIN
6_css3/img/f.jpg


+ 101 - 0
6_css3/练习题1_时钟.html

@@ -0,0 +1,101 @@
+<!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>
+        ul{
+            margin: 0;
+            padding: 0;
+        }
+        li{
+            list-style: none;
+        }
+
+        .box{
+            width: 402px;
+            height: 402px;
+            border:1px dashed black;
+            margin: 100px auto;
+        }
+        .clock{
+            width: 400px;
+            height: 400px;
+            border: 1px solid black;
+            border-radius: 50%;
+            position: relative;
+            transform: rotate(180deg);
+        }
+        .clock li{
+            width: 4px;
+            height: 8px;
+            background-color: #000;
+            position: absolute;
+            top: 0;
+            left: 50%;
+            transform-origin: 0 200px;
+        }
+        .clock li:nth-child(5n + 1){
+            height: 16px;
+        }
+        .clock div{
+            position: absolute;
+            top: 200px;
+            left: 50%;
+            margin-left: -2px;
+            /* transform: translateY(-100%); */
+            transform-origin: 0 0;
+        }
+        .hour{
+            width: 4px;
+            height: 80px;
+            background-color: red;
+        }
+        .minute{
+            width: 4px;
+            height: 120px;
+            background-color: blue;
+        }
+        .seconds{
+            width: 4px;
+            height: 160px;
+            background-color: green;
+        }
+    </style>
+</head>
+<body>
+    <div class="box">
+        <div class="clock">
+            <ul>
+                
+            </ul>
+            <div class="seconds"></div>
+            <div class="minute"></div>
+            <div class="hour"></div>
+        </div>
+    </div>
+    <script>
+        let oUl = document.getElementsByTagName("ul")[0];
+        let oSecond = document.getElementsByClassName("seconds")[0];
+        let oMinute = document.getElementsByClassName("minute")[0];
+        let oHour = document.getElementsByClassName("hour")[0];
+        for(let i=0;i<60;i++){
+            let oLi = document.createElement("li");
+            oLi.style.transform = `rotate(${i*6}deg)`;
+            oUl.append(oLi);
+        }
+
+        setInterval(() => {
+            let nowTimer = new Date();
+            let second = nowTimer.getSeconds();
+            let minute = nowTimer.getMinutes();
+            let hour = nowTimer.getHours();
+            console.log(second);
+            oSecond.style.transform = `rotate(${second*6}deg)`;
+            oMinute.style.transform = `rotate(${minute*6}deg)`;
+            oHour.style.transform = `rotate(${hour*30}deg)`;
+        }, 1000);
+    </script>
+</body>
+</html>