-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
128 lines (114 loc) · 3.5 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>图片弹出</title>
<style>
* {
margin: 0 auto;
padding: 0;
}
#content {
position: relative;
width: 100vm;
height: 100vh;
background: teal;
overflow: hidden;
}
span {
position: absolute;
top: 50px;
left: 45%;
display: block;
width: 100px;
height: 50px;
line-height: 50px;
text-align: center;
color: #fff;
font-size: 20px;
background: #000;
cursor: pointer;
opacity: .3;
}
#mask{
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: #000;
z-index:2;
opacity: .3;
}
#appear{
position: absolute;
bottom: 0;
left: 0;
width: 100vw;
height: 60vh;
background: rgba(255, 60, 53, .7);
z-index: 3;
}
</style>
<script>
window.onload = function () {
var content = document.getElementById("content");
var click=document.createElement("span");
var h=window.innerHeight;
click.id="click";
click.innerHTML="点击";
content.appendChild(click);
click.addEventListener("click", function () {
var mask = document.createElement("div");
mask.id = "mask";
var appear = document.createElement("div");
appear.id = "appear";
appear.style.position="absolute";
appear.style.bottom="-460px";
console.log(appear.style.bottom);
var close = document.createElement("span");
close.id = "close";
close.innerHTML = "关闭";
//文档碎片
var frag = document.createDocumentFragment();
appear.appendChild(close);
frag.appendChild(appear);
frag.appendChild(mask);
var e = event || window.event;
content.appendChild(frag);
e.cancelBubble || e.stopPropagation();
moving(460,0)
});
function moving(speed, ter) {
var bottom_val = parseInt(appear.style.bottom);
if (bottom_val === 0) {
bottom_val = ter;
} else {
bottom_val += speed;
}
appear.style.bottom = bottom_val + "px";
}
content.addEventListener("click",function(){
hidden();
});
function hidden(){
var e=event||window.event;
var target= e.target|| e.srcElement;
if(target.id!="appear"){
moving2(-460,0)
}
}
function moving2(speed) {
var bottom_val = parseInt(appear.style.bottom);
bottom_val += speed;
appear.style.bottom = bottom_val + "px";
content.removeChild(document.getElementById("mask"));
content.removeChild(document.getElementById("appear"));
}
}
</script>
</head>
<body>
<div id="content"></div>
</body>
</html>