hooyantsing's Blog

P181_30_环形菜单触发动画transform-origin

字数统计: 389阅读时长: 2 min
2020/04/23

P181 30 环形菜单触发动画transform-origin

实战案例

效果:

0dbabb9d55dbd437ecc8f1f1c9aabd5f.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!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;
        }

        nav{
            display: flex;
            justify-content: center;
            align-items: center;
            height: 400px;
            width: 400px;
            border-radius: 50%;
            /*cursor: pointer;*/
        }

        nav::after{
            content: '后盾人';
            border-radius: 50%;
            background: #e74c3c;
            width: 200px;
            height: 200px;
            position: absolute;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 3em;
            color: white;
        }
        nav::before{
            content: '';
            border-radius: 50%;
            background: #e74c3c;
            width: 200px;
            height: 200px;
            position: absolute;
        }

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

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

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

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

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

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

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

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

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

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

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

    </style>
</head>
<body>
<nav>
    <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>
</nav>
</body>
</html>
CATALOG