<!DOCTYPE html>
<
html
>
<
head
>
<
title
>页面中常见返回顶部效果(TOP)</
title
>
<
meta
charset
=
"UTF-8"
>
<
link
rel
=
"shortcut icon"
href
=
"static/images/logo.png"
type
=
"image/x-icon"
/>
<
link
rel
=
"stylesheet"
type
=
"text/css"
href
=
"static/font-awesome/css/font-awesome.min.css"
>
<
script
src
=
"static/js/jquery.js"
></
script
>
<
style
type
=
"text/css"
>
*{margin: 0px;padding: 0px;}
body{text-align: center;}
div{width: 1200px;height: 1500px;background: #eee;margin: 30px auto;}
a{text-decoration: none;color: #fff;}
p#back{text-align: center;position: fixed;bottom: 100px;right: 60px;background: #ccc;border-radius: 3px;height: 50px;width: 80px;display: none;}
</
style
>
<
script
>
$(function() {
$(window).scroll(function(){
if($(window).scrollTop()>150){
$('#back').fadeIn(1000)
}else{
$('#back').fadeOut(1000)
}
})
})
</
script
>
</
head
>
<
body
>
<
a
href
=
""
></
a
>
<
div
>网页内容</
div
>
<
p
id
=
"back"
><
a
href
=
""
><
span
class
=
"fa fa-arrow-circle-up"
></
span
><
br
> 返回顶部</
a
></
p
>
</
body
>
</
html
>