How can I create a scrolling/following menu using CSS and Javascript?
I've been experimenting with a scroll/follow menu on this specific page, . The menu is contained within a modal window. After looking at various examples on stackoverflow, the closest one I found was:
However, there are issues when scrolling up, and I feel like there's more to it that I'm missing. I have researched extensively on Stackoverflow and other platforms, trying out different implementations. Could you please review my code below and guide me in the right direction?
Html
<div class=scroller>Xtango</div>
CSS
.scroller {
position: relative;
top: 0px;
width: 100%;
background-color: rgba(255, 255, 255, 0.68);
z-index: 1}
Javascript
$(window).scroll(function() {
if ($(window).scrollTop() > 0) {
$('.scroller').css('top', $(window).scrollTop()); } });