I'm trying to make my Navbar sticky on top of my browser using Tailwindcss. I understand that the sticky property should be added on the first child of the root component, which is why I've added it on the App.jsx file.
See code below:
const App = () => ( <div className="bg-primary w-full overflow-hidden "> <header className="sticky top-0 z-50 sm:px-16 px-6 flex justify-center items-center"> <div className="xl:max-w-[1280px] w-full"> <Navbar /> </div> </header> <div className="bg-primary flex justify-center items-start"> <div className="xl:max-w-[1280px] w-full"> <Hero /> </div> </div> <div className="bg-primary sm:px-16 px-6 flex justify-center items-center"> <div className="xl:max-w-[1280px] w-full"> <Block1/> <Block2 /> <Block3 /> <Footer /> </div> </div> </div> ); However the navbar still gets moving out of the visible browser space once I scoll down. I tried the fixed property, but in this case the navbar is not anymore centered and justified.
How can I get this navbar to remain sticky on top ?