-
Notifications
You must be signed in to change notification settings - Fork 0
/
back-to-top
81 lines (81 loc) · 1.76 KB
/
back-to-top
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>返回顶部</title>
<script src="http://cdn.gbtags.com/jquery/2.1.1/jquery.min.js"></script>
</head>
<style>
body{height:2000px; font-family: '微软雅黑'}
p{text-align: center;margin-top: 200px;font-size: 48px;}
#top{
width:120px;
height: 150px;
position: fixed;
top:400px;
right:20px;
background: url(http://www.gbtags.com/gb/networks/uploadimgthumb/a3a5edca-47b5-457c-824c-3830527a95c9.png);
background-position:0px 0;
text-indent: -9999px;
cursor: pointer;
display: none;
}
.fei{
width:20px;
height:145px;
border-radius:10px 35px;
background: #3281f6;
position: fixed;
top:415px;
right:110px;
display: none;
text-align: center;
padding:5px;
color: #eee;
}
.fei:after{
content: "";
width:0;
height: 0;
position: fixed;
top:475px;
right:90px;
border-width:10px;
border-style:solid;
border-color: transparent transparent transparent #3281f6;
}
</style>
<script>
$(function(){
$(window).scroll(function(){
if($(window).scrollTop()>10){
$("#top").css("display","block");
}else{
$("#top").css("display","none");
}
});
$("#top").mouseover(function(){
$(this).css("background-position","-149px 0")
$(".fei").css("display","block");
});
$("#top").mouseout(function(){
$(this).css("background-position","0 0");
$(".fei").css("display","none");
});
$("#top").click(function(){
$("html,body").animate({scrollTop:0},300)
$(".fei").css("display","none");
});
});
</script>
<body>
<p>极客标签</p>
<p>极客标签</p>
<p>极客标签</p>
<p>极客标签</p>
<p>极客标签</p>
<p>极客标签</p>
<div id="top">返回顶部</div>
<span class="fei">带你装逼带你飞</span>
</body>
</html>