Рипал: Бармен
Ссылка на скачивание!
Вставляем в Нижнюю часть сайта в самый низ:
Код
<a href="#top" class="back-to-top" style="display: inline;"><span>Back to Top</span></a>
CSS:
Код
a.back-to-top {
position: fixed;
bottom: 2em;
right: 1em;
text-decoration: none;
text-indent: -9999px;
display: none;
width: 80px;
z-index: 1000;
}
a.back-to-top span {
display: block;
background: url(/scroll/img/rift-sprite2.png) 93.75% 43.5% no-repeat;
background-size: 300% 350%;
height: 0;
max-width: 80px;
padding-bottom: 100%;
width: 100%;
}
JS (в нижнюю часть сайта):
Код
<script type="text/javascript">
var offset = 220;
var duration = 500;
$(window).resize(function() {
var h = ($('.slide').width()) * .5625;
$('.slide a').css('height', h);
});
$(window).scroll(function() {
var h = ($('.slide').width()) * .5625;
$('.slide a').css('height', h);
if ($(this).scrollTop() > offset) {
$('.back-to-top').fadeIn(duration);
} else {
$('.back-to-top').fadeOut(duration);
}
});
$('.back-to-top').click(function(event) {
event.preventDefault();
$('html, body').animate({
scrollTop: 0
}, duration);
return false;
})
</script>