hooyantsing's Blog

P178_27_纯CSS电子时钟绘制表盘

字数统计: 293阅读时长: 1 min
2020/04/22

P178 27 纯CSS电子时钟绘制表盘

实战案例

效果:

c33c94647c4471b5a3adb3dc1b70c4a3.png

源码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }
        body{
            background: #2c3e50;
            width: 100vw;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        main{
            width: 400px;
            height: 400px;
            border-radius: 50%;
            background: linear-gradient(to right,#f1c40f,#e67e22,#e74c3c);
            position: relative;
            z-index: -2;
        }
        main:after{
            content: '';
            background: #2c3e50;
            position: absolute;
            width: 90%;
            height: 90%;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
            border-radius: 50%;
            z-index: -1;
        }
        .line{
            position: absolute;
            width: 80%;
            height: 80%;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
            border-radius: 50%;
        }
        .line div{
            width: 8px;
            height: 100%;
            position: absolute;
            background: white;
            left: 50%;
        }
        .line div:nth-child(1){
            transform: rotateZ(0);
        }
        .line div:nth-child(2){
            transform: rotateZ(30deg);
        }
        .line div:nth-child(3){
            transform: rotateZ(60deg);
        }
        .line div:nth-child(4){
            transform: rotateZ(90deg);
        }
        .line div:nth-child(5){
            transform: rotateZ(120deg);
        }
        .line div:nth-child(6){
            transform: rotateZ(150deg);
        }
    </style>
</head>
<body>
<main>
    <div class="line">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </div>
</main>
</body>
</html>
CATALOG