Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Collin Retkowski
6,542 PointsBootstrap navbar Hover CSS
So i am making a navbar in Bootstrap but when i changed the text color to white it removed the hover color. I tried to add it through CSS but something is not working. Here is the code.
<style>
ul li a:hover {
color:grey;
}
</style>
</head>
<body>
<!-- Navigation -->
<ul class="nav justify-content-center navbar-dark bg-dark">
<li class="nav-item">
<a class="nav-link text-white" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="#">Things To Do</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="#">Map</a>
</li>
<li class="nav-item">
<a class="nav-link text-white" href="#">Contacts</a>
</li>
</ul>
<!-- /Navigation -->
1 Answer
Steven Parker
243,318 PointsWhat Alex is suggesting is a bit unconventional. The recommended practice is for custom CSS to override Bootstrap, as you are doing. The trick is to only do things in your custom CSS that can't be done the "Boostrap way", and to avoid doing things that have side effects on the Bootstrap.
Anyway, the issue here is that the Bootstrap class adds the white color in a way that can't be overridden as easily as the default color can. But you can compensate like this:
color:grey !important;
Alex Davis
35,050 PointsAlex Davis
35,050 PointsYour CSS is overriding your bootstrap. Try setting it up where your CSS comes first and your BS after that. This it'll make it where your CSS is read first and should be applied first.
Also do you have a separate page for your CSS? You should avoid using style tags and modify in CSS. It has a lot more flexibility.