Created
July 13, 2018 20:54
-
-
Save arianimartins/1a81c1fb97357df352670f463d50a9b0 to your computer and use it in GitHub Desktop.
Blog - Top Button
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
<!-- Colocar logo acima da tag <footer> --> | |
<a href="#" class="topbutton"> | |
<i class="fa fa-angle-up fa-lg"></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
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; | |
}); | |
}); |
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
.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