hooyantsing's Blog

P180_29_transform-origin技术做动态旋转菜单

字数统计: 312阅读时长: 1 min
2020/04/23

P180 29 transform-origin技术做动态旋转菜单

实战案例

效果:

c4cf9697b7376cc7ae5a791dab14f872.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
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }

        body {
            height: 100vh;
            width: 100vw;
            display: flex;
            justify-content: center;
            align-items: center;
            background: #2c3e50;
        }

        ul {
            width: 300px;
            height: 300px;
            background: black;
            list-style-type: none;
            position: relative;
        }

        li {
            width: 60px;
            height: 60px;
            background: #e67e22;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 3em;
            color: white;
            border-radius: 50%;
            position: absolute;
            transform-origin: 150px 150px;
            transition: 2s;
        }

        ul:hover li:nth-child(1) {
            transform: rotateZ(0);
        }

        ul:hover li:nth-child(2) {
            transform: rotateZ(40deg);
        }

        ul:hover li:nth-child(3) {
            transform: rotateZ(80deg);
        }

        ul:hover li:nth-child(4) {
            transform: rotateZ(120deg);
        }

        ul:hover li:nth-child(5) {
            transform: rotateZ(160deg);
        }

        ul:hover li:nth-child(6) {
            transform: rotateZ(200deg);
        }

        ul:hover li:nth-child(7) {
            transform: rotateZ(240deg);
        }

        ul:hover li:nth-child(8) {
            transform: rotateZ(280deg);
        }

        ul:hover li:nth-child(9) {
            transform: rotateZ(320deg);
        }

    </style>
</head>
<body>
<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    <li>6</li>
    <li>7</li>
    <li>8</li>
    <li>9</li>
</ul>
</body>
</html>
CATALOG