-
Notifications
You must be signed in to change notification settings - Fork 0
/
css特效.html
171 lines (146 loc) · 3.37 KB
/
css特效.html
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!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>
* {
padding: 0;
margin: 0;
}
.date-container {
perspective: 800px;
/* 设置透视效果 */
}
.date-container span {
display: inline-block;
transform-style: preserve-3d;
/* 保持元素在三维空间中不变形 */
animation: flipDate 4s infinite linear;
/* 应用动画并无限重复 */
}
@keyframes flipDate {
0% {
transform: rotateY(0deg);
/* 初始状态为正常显示 */
}
50% {
transform: rotateY(-90deg) scaleX(0.7);
/* 将文字向上翻转并放大 */
}
100% {
transform: rotateY(0deg);
/* 返回到原始位置 */
}
}
.divbox {
position: relative;
height: 20px;
}
.div1,
.div_zhong,
.div2,
.div3 {
font-size: 20px;
font-weight: bold;
line-height: 1;
position: absolute;
background-color: aliceblue;
overflow: hidden;
}
.div1 {
height: 10px;
top: 0;
z-index: 3;
transform: rotateX(0deg);
transform-origin: bottom;
transition: all 0.5s;
animation: flaptop 1s infinite;
}
.div_zhong {
height: 10px;
bottom: 0;
z-index: 3;
line-height: 0px;
transform-origin: top;
transform: rotateX(-90deg);
transition: all 0.3s;
animation: flapdow 1s infinite;
}
.div2 {
height: 10px;
bottom: 0;
z-index: 2;
line-height: 0px;
}
.div3 {
z-index: 1;
}
@keyframes flaptop {
0% {
transform: rotateX(0deg);
}
50% {
transform: rotateX(-90deg);
}
100% {
transform: rotateX(-180deg);
}
}
@keyframes flapdow {
0% {
/* transform: rotateX(-180deg); */
}
50% {
transform: rotateX(-90deg);
}
100% {
transform: rotateX(0deg);
}
}
</style>
</head>
<body>
<div id="app">
<!-- <div class="date-container">
<span>2021</span><br />
<span>January</span><br />
<span>15th</span>
</div> -->
</div>
<div class="divbox">
<div class="div1">
00
</div>
<div class="div2">
00
</div>
<div class="div_zhong">00</div>
<div class="div3">
00
</div>
</div>
<script>
function getDate() {
setInterval(() => {
const date = new Date();
const year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
const hours = date.getHours();
let minutes = date.getMinutes();
let second = date.getSeconds();
minutes = minutes > 9 ? minutes : '0' + minutes;
month = month > 9 ? month : '0' + month;
day = day > 9 ? day : '0' + day;
document.querySelector('.div1').innerText = second > 9 ? second : '0' + second
document.querySelector('.div2').innerText = second > 9 ? second : '0' + second
document.querySelector('.div_zhong').innerText = second > 9 ? second + 1 : '0' + (second + 1)
document.querySelector('.div3').innerText = second > 9 ? second + 1 : '0' + (second + 1)
}, 1000);
}
getDate()
</script>
</body>
</html>