-
Notifications
You must be signed in to change notification settings - Fork 0
/
js.js
63 lines (53 loc) · 1.53 KB
/
js.js
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
(function() {
var header = document.querySelector('header');
var nav = document.getElementById('rightnav');
var width = nav.clientWidth;
var height = nav.clientHeight;
var winWidth = window.innerWidth;
var winHeight = window.innerHeight;
var btn = document.createElement('div');
header.style.position = 'fixed';
header.style.zIndex = '10';
header.style.top = '0';
header.style.left = '0';
header.style.width = '100%';
nav.style.position = 'fixed';
nav.style.width = width + 'px';
if(winWidth > 1200) {
nav.style.height = '560px';
nav.style.overflowY = 'auto';
} else {
nav.style.display = 'none';
nav.style.zIndex = '5';
nav.style.width = '50%';
nav.style.top = '0';
nav.style.right = '0';
nav.style.height = '100%';
nav.style.overflowY = 'auto';
btn.innerHTML = '菜单';
btn.style.position = 'fixed';
btn.style.zIndex = '10';
btn.style.right = '20px';
btn.style.bottom = '40px';
btn.style.width = '50px';
btn.style.height = '50px';
btn.style.lineHeight = '50px';
btn.style.textAlign = 'center';
btn.style.color = '#fff';
btn.style.fontSize = '12px';
btn.style.borderRadius = '25px';
btn.style.backgroundColor = '#333';
document.body.appendChild(btn);
btn.onclick = (e) => {
e.stopPropagation();
if(nav.style.display === 'none') {
nav.style.display = 'block';
} else {
nav.style.display = 'none';
}
}
document.onclick = () => {
nav.style.display = 'none';
}
}
})();