Answers for "sticky navigation bar css"

CSS
4

sticky navbar

<!-- The simplest solution: NO JAVASCRIPT, ONLY 3 LINES OF CODE.-->
<!-- Please vote if you find this useful -->

            <nav style="position: fixed;top; 0px;left: 0px;right: 0px;background-color: #ccc;padding: 20px;color: #fff!important;">
                <a href="#">MY COMPANY</a>
            </nav>
Posted by: Guest on July-26-2021
0

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