简体   繁体   中英

Sticky Navigation Menu

Here is the link: JSFIDDLE

$('.main-menu').addClass('fixed');

How come the fixed element is flickering whenever the fixed class is added?

You're constantly removing and re-adding the fixed CSS attribute because everytime you scroll, the top offset changes. What you want to do is store it in a variable on load, then compare against that variable. JSFiddle: http://jsfiddle.net/j44xdv3m/6/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM