Skip to content

Instantly share code, notes, and snippets.

@agragregra
Last active December 25, 2022 19:51
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 35 You must be signed in to fork a gist
  • Save agragregra/eac9233a7dd7a3b23dfa7102c14e04c5 to your computer and use it in GitHub Desktop.
Save agragregra/eac9233a7dd7a3b23dfa7102c14e04c5 to your computer and use it in GitHub Desktop.
Scroll Top Button
<div class="top" title="Наверх"><i class="fa fa-angle-double-up"></i></div>
.top
position: fixed
bottom: 25px
background-color: #E0E0E0
border-radius: 10em
color: #666
font-size: 26px
width: 50px
height: 50px
line-height: 50px
text-align: center
cursor: pointer
transition: all .25s ease
right: -100px
z-index: 12
opacity: .5
&.active
right: 30px
i
line-height: 0
&:hover
color: #fff
background-color: $accent
opacity: 1
/* Extra Small Devices, Phones */
@media only screen and (max-width : 480px)
.top
bottom: 20px
&.active
right: 20px
$('.top').click(function() {
$('html, body').stop().animate({scrollTop: 0}, 'slow', 'swing');
});
$(window).scroll(function() {
if ($(this).scrollTop() > $(window).height()) {
$('.top').addClass("active");
} else {
$('.top').removeClass("active");
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment