Last active
December 22, 2017 05:23
-
-
Save nafilimonov/ed28f2093cc08524eef0e7503b735897 to your computer and use it in GitHub Desktop.
JS. Кнопка вверх
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a id="go-to-top" href="#" class="go-to-top" role="button" title="Вверх"> | |
<i class="fa fa-chevron-up" aria-hidden="true"></i> | |
</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(window).scroll(function() { | |
// Высота проявления кнопки | |
if ($(this).scrollTop() > 100) { | |
$('#go-to-top').fadeIn(); | |
} else { | |
$('#go-to-top').fadeOut(); | |
} | |
}); | |
$('#go-to-top').click(function() { | |
$('body,html').animate({scrollTop: 0}, 2000); | |
return false; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.go-to-top { | |
cursor: pointer; | |
display: none; | |
position: fixed; | |
bottom: 15px; | |
right: 15px; | |
z-index: 10; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Для иконки используется http://fontawesome.io/