-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex-079.html
101 lines (84 loc) · 2.07 KB
/
ex-079.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>[實作] 隱藏側欄選單</title>
<style type="text/css">
html, body{
padding: 0; margin: 0;
}
.window{
display: block;
position: fixed;
left: 0;
top: 120px;
width: 140px;
height: 400px;
background-color: #000;
/* transition: left .7s; */
}
.tag{
display: block;
position: absolute;
text-decoration: none;
color: #fff;
font-size: 20px;
width: 1em;
height: auto;
overflow: hidden;
top: 30%;
right: -2em;
padding: 10px;
background-color: #f00;
border-radius: 0 5px 5px 0;
}
.tag:hover{
color: yellow;
}
.links a{
display: block;
width: 100px; height: 100px;
border-radius: 50%;
overflow: hidden;
margin: 20px;
background-color: #fff;
}
.links img{
width: 100px; height: 100px;
}
</style>
</head>
<body>
<div class="window">
<a href="#" class="tag">收合</a>
<div class="links">
<a target="_blank" href="https://www.facebook.com">
<img src="facebook.png" alt="">
</a>
<a target="_blank" href="https://google.com">
<img src="https://cdn4.iconfinder.com/data/icons/new-google-logo-2015/400/new-google-favicon-128.png" alt="">
</a>
<a target="_blank" href="https://5xruby.tw">
<img src="https://avatars1.githubusercontent.com/u/7474661?v=3&s=200" alt="">
</a>
</div>
</div>
<script src="scripts/jquery-3.1.0.js"></script>
<script type="text/javascript">
// 1. 加入展開與收合的判斷與文字
// 2. 請完成展開的功能
$('.tag').on('click', function(e){
var that = this;
e.preventDefault();
console.log($('.window').position().left);
if($('.window').position().left === 0)
$(this).parent().animate({'left':'-140px'},5000,function(){
console.log($(that).position().left);
});
else if($('.window').position().left === -140)
$(this).parent().animate({'left':'0px'},5000);
});
</script>
</body>
</html>