I am trying to create a pure 100% CSS (no jQuery) "Back to Top" button but I would like the button to show only if the visitor scrolls down the page.
Is it possible to check that with CSS somehow? So if visitor scrolled down a bit show the "Back to Top" button.
Thanks!
Determine by Cursor Location
One way you could do this would be to only show the
.toTop
element when the user is hovering over the content of the page itself, well below the header, and navigation links:You can see the effect here: http://jsfiddle.net/GFfbe/1/
Or, Slowly Uncover It
Alternatively, you could slowly uncover the
.toTop
link with another element. In the example below, I use the body's pseudo element::before
to cover up the.toTop
element, and slowly reveal it as the user scrolls:You can see this effect here: http://jsfiddle.net/GFfbe/2/