I recently added a "back-to-top" button to my website.
Here is the HTML:
<div class="scroll-top scroll-is-not-visible">
<a href="#0"><i class="fa fa-angle-up" aria-hidden="true"></i></a>
</div>
<footer class="site-footer">
...
</footer>
And here is the CSS:
.scroll-top{
position: fixed;
right: 50px;
bottom: 50px;
display: flex;
align-items: center;
justify-content: center;
}
.scroll-is-not-visible{
visibility: hidden
}
.scroll-is-visible{
visibility: visible;
opacity: 1;
}
.scroll-fade-out{
opacity: .5;
}
Currently, the button overlaps the footer when I scroll down completely. I want the button to remain at a defined position when the footer is not in view, and move 50px above the footer when the footer becomes visible in the viewport. Essentially, I want the button to scroll with the content when the footer is in view.
If my explanation is unclear, please let me know.
Thank you!