Answers for "sticky navigation in css"

CSS
1

css sticky navigatiojn

nav {
	position:sticky;
	top:0;
}

/*Top can be replaced with bottom, left, or right 
	depending on what you want :) */
Posted by: Guest on November-05-2020
1

sticky navigation bar on scroll

// sticky Header js plugin
let w_out_sticky = document.querySelector(".w-out")// terget class or id
 // hear is  scroll logic
window.addEventListener('scroll', () => {
    window.scrollY > 300 ? w_out_sticky.classList.add("sticky") : w_out_sticky.classList.remove("sticky")
})
Posted by: Guest on July-15-2021

Browse Popular Code Answers by Language