简体   繁体   中英

how do i get a navigation that scrolls with page and stick when it reaches the top nav with plain javascript

How can make a div elememt move up when a user scrolls and then stay fixed when it reaches the top of the page? I already have a fixed bar under which i expect this div to stay.

What you want is a sticky block. There is a (relatively) new CSS feature position: sticky , but unfortunately it works not in all browsers. You can use it in combination with a polyfill

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