Skip to content

Instantly share code, notes, and snippets.

@arianimartins
Created July 13, 2018 20:54
Show Gist options
  • Save arianimartins/1a81c1fb97357df352670f463d50a9b0 to your computer and use it in GitHub Desktop.
Save arianimartins/1a81c1fb97357df352670f463d50a9b0 to your computer and use it in GitHub Desktop.
Blog - Top Button
<!-- Colocar logo acima da tag <footer> -->
<a href="#" class="topbutton">
<i class="fa fa-angle-up fa-lg"></i>
</a>
jQuery(document).ready(function($){
var offset = 100;
var speed = 250;
var duration = 500;
$(window).scroll(function(){
if ($(this).scrollTop() < offset) {
$('.topbutton') .fadeOut(duration);
} else {
$('.topbutton') .fadeIn(duration);
}
});
$('.topbutton').on('click', function(){
$('html, body').animate({scrollTop:0}, speed);
return false;
});
});
.topbutton {
background: none repeat scroll 0 0 rgb(46, 142, 67);
border-radius: 50%;
color: rgb(255,255,255) !important;
bottom: 2em;
box-shadow: 4px 4px 10px rgba(0,0,0,0.5);
cursor: pointer;
display: none;
height: 3rem;
line-height: 3rem;
position: fixed;
right: 1.5em;
text-align: center;
text-decoration: none;
transition: border 0.3s ease-in-out 0s;
width: 3rem;
z-index: 999999;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment