a_tree_gnome Posted February 2, 2022 Posted February 2, 2022 (edited) Hello, first off, I would like to state that I am using this code: <style> #myBtn { width: 50px; height: 50px; display: none; position: fixed; bottom: 20px; right: 30px; z-index: 1; border: none; outline: none; font-size: 25px !important; color: #17306e; cursor: pointer; padding: 10px 10px 10px 11px; border-radius: 50%; box-shadow: 1px 1px 5px #000; // Change the hex code in the next line to change background color background-color: #cbcccd; } #myBtn:hover { background-color: #aeaeae; } </style> <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/js/all.min.js" crossorigin="anonymous"></script> <button onclick="topFunction()" id="myBtn" title="Go to top"> <i class="fas fa-arrow-up"></i> </button> <script> window.onscroll = function() {scrollFunction()}; function scrollFunction() { if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { document.getElementById("myBtn").style.display = "block"; } else { document.getElementById("myBtn").style.display = "none"; } } function topFunction() { $('html,body').animate({ scrollTop: 0 }, 1000); } </script> With that being said, the Jump to Top button only seems to appear once I've hit the bottom of a page. However, after I reach the bottom of the page, the button stays visible as I scroll back up. So my question is: what code do I need to add/modify to make the Jump to Top button stay visible as soon as you start to scroll down? I don't have a website to share, since my trial has expired. Thanks! Edited February 2, 2022 by a_tree_gnome
tuanphan Posted February 7, 2022 Posted February 7, 2022 Hi. Can you share link to page where you have problem? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment