Created
February 1, 2021 11:17
-
-
Save Rameshwar-ghodke/c2f01ed02296ba1cb7ddc68ea84a7cff to your computer and use it in GitHub Desktop.
Go to Top , Add page scroll to top effect using j-query, HTML and css
This file contains hidden or 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 class="gototop"></div> | |
| .gototop { | |
| transition: background 0.35s ease; | |
| background-size: 100% 100% !important; | |
| background-image: // set image or icon path | |
| background-color: #ffffff; | |
| width: 40px; | |
| height: 40px; | |
| bottom: 5%; | |
| right:20px; | |
| border-radius: 5px; | |
| padding: 0px; | |
| position: fixed; | |
| Z-index: 10001; | |
| display: none; | |
| } | |
| <script> jQuery(document).ready(function(){ | |
| //Check to see if the window is top if not then display button | |
| jQuery(window).scroll(function(){ | |
| if (jQuery(this).scrollTop() > 100) { | |
| jQuery('.gototop').fadeIn(); | |
| } else { | |
| jQuery('.gototop').fadeOut(); | |
| } | |
| }); | |
| //Click event to scroll to top | |
| jQuery('.gototop').click(function(){ | |
| jQuery('html, body').animate({scrollTop : 0},800); | |
| return false; | |
| }); | |
| }); </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment