-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtishi.html
85 lines (77 loc) · 1.78 KB
/
tishi.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
<!DOCTYPE html>
<html>
<head>
<style>
/* CSS样式 */
.modal {
display: none; /* 默认隐藏 */
position: fixed;
z-index: 9999;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 300px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
animation: show-modal 0.3s ease;
}
.modal-close {
color: #aaa;
float: right;
font-size: 16px;
font-weight: bold;
cursor: pointer;
margin-top: 10px;
}
.modal-close:hover,
.modal-close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
@keyframes show-modal {
0% {
opacity: 0;
transform: translate(-50%, -50%) scale(0.8);
}
100% {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
}
}
</style>
</head>
<body>
<div class="modal" id="myModal">
<div class="modal-content">
<h2>提醒</h2>
<p>欢迎访问</p>
<button class="modal-close">关闭</button>
</div>
</div>
<script>
// JavaScript代码
window.addEventListener('DOMContentLoaded', function() {
var modal = document.getElementById('myModal');
var span = document.getElementsByClassName('modal-close')[0];
modal.style.display = 'block';
span.addEventListener('click', function() {
modal.style.display = 'none';
});
window.addEventListener('click', function(event) {
if (event.target == modal) {
modal.style.display = 'none';
}
});
});
</script>
</body>
</html>