Created
March 19, 2015 09:34
-
-
Save AlexMcowkin/3f81c1f2dfffdb1e3f2c to your computer and use it in GitHub Desktop.
Back to TOP
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
/* scroll to top buttton */ | |
a.scrollToTop{ | |
width:75px; | |
height:75px; | |
text-align:center; | |
background: whiteSmoke; | |
text-decoration: none; | |
position:fixed; | |
bottom:30px; | |
right:30px; | |
display:none; | |
background: url('../images/scroll_to_top.png') no-repeat; | |
z-index: 100; | |
} | |
a:hover.scrollToTop{ | |
text-decoration:none; | |
cursor: pointer; | |
} |
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
<div id="scroll-to-top"><a href="#top" class="scrollToTop" title='вверх'></a></div> |
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
$(document).ready(function(){ | |
//Check to see if the window is top if not then display button | |
$(window).scroll(function(){ | |
if ($(this).scrollTop() > 300) { | |
$('.scrollToTop').fadeIn(); | |
} else { | |
$('.scrollToTop').fadeOut(); | |
} | |
}); | |
//Click event to scroll to top | |
$('.scrollToTop').click(function(){ | |
$('html, body').animate({scrollTop : 0},800); | |
return false; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment