Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change color of bootstrap navbar on hover link?

I want to know how to change the color of the links when you hover over them in the nav bar, as currently they are an ugly color.

Thanks for any suggestions?

HTML:

<div class="container">     <div class="navbar">         <div class="navbar-inner">             <ul class="nav">                 <li class="active"><a href="#">Home</a></li>                 <li><a href="#">Link One</a></li>                 <li><a href="#">Link Two</a></li>                 <li><a href="#">Link Three</a></li>             </ul>         </div>     </div> </div> 
like image 879
Callum Avatar asked May 18 '13 15:05

Callum


People also ask

How do you change the color of hovering in CSS?

Changing link color on hover using CSS To change the color of your link on hover, use the :hover pseudo property on the link's class and give it a different color.


2 Answers

For Bootstrap 3 this is how I did this based on the default Navbar structure:

.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus {     background-color: #FFFF00;     color: #FFC0CB; } 
like image 160
Leniel Maccaferri Avatar answered Sep 24 '22 22:09

Leniel Maccaferri


This is cleaner:

ul.nav a:hover { color: #fff !important; } 

There's no need to get more specific than this. Unfortunately, the !important is necessary in this instance.

I also added :focus and :active to the same declaration for accessibility reasons and for smartphone/tablet/touchscreen users.

like image 33
trebor1979 Avatar answered Sep 24 '22 22:09

trebor1979