一个简单的弹窗

原来只用css也可以写出来一个漂亮的弹窗

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
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type='text/css'>
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity .5s;
visibility: hidden;
opacity: 0;
z-index: 10000
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.modal {
min-width:400px;
max-width: 45%;
position: relative;
margin: auto;
padding: 1.5rem;
background: #fff;
border-radius: 4px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
transition: .5s;
opacity: 0;
transform: scale(1.1);
}
.overlay:target > .modal {
transform: translateY(60%) scale(1);
transition-timing-function: cubic-bezier(0.8, 0, 0, 1.5);
opacity: 1;
}
</style>
</head>
<body>
<div class='overlay' id='pop'>
<div class='modal'>
<a href='#'>关闭</a>
</div>
</div>
<a href='#pop'>显示</a>
</body>
</html>