I wanted to create a sticky navigation with some elements from bulma and initially it worked when i tested it with angular. However, I have migrated to react due to some technical reasons and the navigation bar doesnt seem to be sticky anymore, it will scroll like a normal page. I don't have a lot of experience with react and I tried to create pages and components and importing different components such as navigation+herobody+footer.
Here is the html and the css which I used;
<nav className="navbar mx-auto">
<div className="container">
<div id="navMenu" className="navbar-menu">
<div className="navbar-start ml-4">
<a className="navbar-item" onClick={() => setPage('home')}>
Home
</a>
<a className="navbar-item" onClick={() => setPage('pricing')}>
Pricing
</a>
<div className="navbar-item has-dropdown is-hoverable">
<a className="navbar-link is-arrowless">
Solutions
</a>
<div className="navbar-dropdown">
<a className="navbar-item" onClick={() => setPage('blog1')}>
Item1
</a>
</div>
</div>
</div>
<div className="navbar-end mr-3">
<div className="navbar-item">
<div className="buttons">
<a className="button is-white is-rounded">Contact us</a>
<a className="button is-link is-rounded">Login</a>
</div>
</div>
</div>
</div>
</div>
</nav>
.navbar {
background: rgba(255, 255, 255, 0.2);
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
backdrop-filter: blur(5px);
-webkit-backdrop-filter: blur(5px);
border: 1px solid rgba(0, 0, 0, 0.3);
border-radius: 25px;
width: 90%;
position:sticky;
position: -webkit-sticky;
top: 0.5rem;
z-index: 10; /* to make sure it's above other elements when scrolling */
}
I have already tried to make the nav position:fixed;top:0.5rem
however it still doesn't seem to work.
I personally believe it is a problem of how my components are put together in react rather than the css or html.
Any explanation or help is appreciated!
Add !important
after the position:sticky
due to bulma overwriting the css.