index.html
<script>
$(document).ready(function(){
$("#back-top").hide();
$(function () {
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('#back-top').fadeIn();
} else {
$('#back-top').stop().fadeOut();
}
});
$('#back-top a').click(function () {
$('body,html').animate({
scrollTop: 0
}, 600);
return false;
});
});
});
</script>
</head>
<body id="top">
<p id="back-top"><a href="#top"><span>Back to Top</span></a></p>
</body>
</html>
@charset "utf-8";
#back-top {
position: fixed;
bottom: 50px;
right: 180px;
}
#back-top a {
width: 100px;
height: 100px;
display: block;
background: url(img/toTop.png) no-repeat;
text-decoration: none;
opacity: 0.5;
}
#back-top a:hover {
opacity: 1;
}
#back-top span {
width: 100px;
height: 120px;
display: block;
padding-top: 105px;
font-size: 12px;
text-align: center;
}