Created
July 6, 2016 16:57
-
-
Save Robin-bob/4d386c5b2e6601b8ac87798e9a25b5db to your computer and use it in GitHub Desktop.
fixed button if footer scroll to top page
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
<!-- to up button --> | |
<div class="to-up"> | |
<i class="fa fa-arrow-up" aria-hidden="true"></i> | |
</div> | |
<!-- end to up 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
//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; | |
}); |
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
//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); | |
} | |
} |
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
/! 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