-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2022.11.15上.html
142 lines (127 loc) · 3.77 KB
/
2022.11.15上.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
background-color: #000;
}
.wrap {
cursor: pointer;
position: relative;
width: 200px;
height: 200px;
margin: 100px auto;
background-color: #000;
animation: move 1s linear infinite alternate;
}
/* .text_box {
background-color: #fff;
position: absolute;
top: 50%;
left: 50%;
text-align: center;
color: #ff437b;
z-index: 100;
} */
@keyframes move {
0% {
transform: scale(1);
}
100% {
transform: scale(1.2);
}
}
.left,
.right {
width: 100px;
height: 160px;
float: left;
background-color: pink;
border-radius: 50px 50px 0 0;
box-shadow: 0 0 20px 0 pink;
}
.left {
transform: translateX(29px) rotate(-45deg);
}
.right {
transform: translateX(-29px) rotate(45deg);
}
.desc {
color: pink;
display: none;
}
</style>
</head>
<body>
<div class="desc">
<span id="text"></span>
<span id="bar">|</span>
</div>
<div class="wrap" onclick="love()" id="show">
<div class="left"></div>
<div class="right"></div>
<!-- <div class="text_box">
张静怡
<button id="btn" onclick="fn()">❤️</button>
</div> -->
</div>
</body>
<script>
function love() {
console.log(11);
var box = document.getElementsByClassName('wrap')[0]
var box1 = document.getElementsByClassName('desc')[0]
box.style.display = 'none'
box1.style.display = 'block'
}
var i = 0;
var str = "世界奇奇怪怪,愿你可可爱爱!";
//自动打字效果
function typing() {
var mydiv = document.getElementById("text");
document.getElementById("bar").style.cssText = "display:none";
mydiv.innerText = str.substring(0, i++) + (i > str.length ? "" : "|");
var typingTimer = setTimeout(typing, 350);
if (i > str.length) {
clearTimeout(typingTimer);
// 竖杠闪烁效果
var twinkleTimer = setInterval(twinkle, 350);
setTimeout(function () {
clearInterval(twinkleTimer);
document.getElementById("bar").style.cssText = "display:none";
//自动删除文字效果
// deleteText();
}, 3000);
}
}
typing();
//自动删除文字效果
function deleteText() {
var mydiv = document.getElementById("text");
mydiv.innerText = str.substring(0, i--) + "|";
var deleteTextTimer = setTimeout(deleteText, 50);
if (i < 0) {
clearTimeout(deleteTextTimer);
//删除完后,自动打字,达到循环
typing();
}
}
// 竖杠闪烁效果
var flag = 0;
function twinkle() {
if (flag) {
document.getElementById("bar").style.cssText = "color:#fff;";
flag = 0;
} else {
document.getElementById("bar").style.cssText = "color:#ffffff47;";
flag = 1;
}
}
</script>
</html>