Topic: React navbar color when collapsed
Wasserman pro asked 6 years ago
Jakub Mandra staff answered 6 years ago
.navbar.scrolling-navbar.top-nav-collapse { background: #ff0000; }'top-nav-collapse' is added to the navbar while scroll, so you just need to describe which color you want. And we need to remember about specificity here. This should do the work. Also we want to implement better solution in future release. Stay tuned! Best regards, Jakub from MDB
Jakub Mandra staff answered 6 years ago
Hello,
TO change navbar color you have to add property 'color':
color="indigo"
If you want to dynamicaly change color of your navbar you have to store your color in state.
For example:
this.state = { collapse: false, isWideEnough: false, color: 'indigo' } onClick() { this.setState({ collapse: !this.state.collapse, color: 'default' }); } <Navbar color={this.state.color} dark expand="md" scrolling>
Hope i helped.
Best regards
Jakub from MDB
Wasserman pro commented 6 years ago
Hey Jakub, thanks ir did help change the color when click, but I am looking to change the navbar when scrolling as you can see in this great demo https://mdbootstrap.com/previews/docs/latest/html/intros/intro-app.html At first the navbar is transparnt and when scrolling down it changes it's color to indigo can you please explian how to change it so when scroll it will be red for example? I try changing the css class .navbar:not(.top-nav-collapse) with and without !important did not work Thank you for your helpFREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Pro
- Premium support: No
- Technology: MDB React
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No