Skip to content

Instantly share code, notes, and snippets.

@Robin-bob
Created July 6, 2016 16:57
Show Gist options
  • Save Robin-bob/4d386c5b2e6601b8ac87798e9a25b5db to your computer and use it in GitHub Desktop.
Save Robin-bob/4d386c5b2e6601b8ac87798e9a25b5db to your computer and use it in GitHub Desktop.
fixed button if footer scroll to top page
<!-- to up button -->
<div class="to-up">
<i class="fa fa-arrow-up" aria-hidden="true"></i>
</div>
<!-- end to up button -->
//to up
$(window).scroll(function(){
if ($(this).scrollTop() >= 200) {
$('.to-up').show();
} else {
$('.to-up').hide();
}
});
$('.to-up').on('click', function(){
$("html, body").animate({ scrollTop: 0 }, "slow");
return false;
});
//toup
.to-up {
position: fixed;
width: 40px;
height: 40px;
line-height: 40px;
background-color: rgba(255,255,255,.4);
text-align: center;
color: $blue;
cursor: pointer;
z-index: 10;
right: 7px;
bottom: 7px;
border-radius: 50%;
transition: background-color .2s, color .2s;
display: none;
&:hover, &:focus {
color: #fff;
background-color: rgba(37,121,191,.4);
}
}
/! to up button
.to-up
i.fa.fa-arrow-up aria-hidden="true"
/! end to up button
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment