Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 141980

Change css after certain amount of scroll (positioning) but change back if scrolled up

$
0
0

I have a full width menu in divi that sits right below the header. The header is set to sticky and shrinks when you scroll. The full width menu below it does not shrink with it. I have tried some script in the page as a code module but notta. Here is what I used:

< script >
  $(window).scroll(function() {
    if ($(window).scrollTop() >= 40) { //looking for the window to scroll to 40px 
      $('#divi-sticky-header').css({
        position: 'fixed',
        z - index: '999',
        width: '100%',
        top: '45px', - webkit - transition: 'all .25s ease-out 0s',
        transition: 'all .25s ease-out 0s'
      });
    } else {
      $('#divi-sticky-header').css({
        position: 'fixed',
        z - index: '999',
        width: '100%',
        top: '60px'
      });
    }
  }); </script>

any suggestions? I just need the sub-nav full width menu to shrink with the header. It actually doesn't change size, just the top positioning. Or is there another way to accomplish this? thanks,


Viewing all articles
Browse latest Browse all 141980

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>