I have a navbar menu in Bootstrap like this:
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Menu Item 1</li>
<li><a href="#">Menu Item 2</a></li>
<li><a href="#">Menu Item 3</a></li>
<li><a href="#">Change Color of this Menu Item</a></li>
</ul>
I would like to change the color of the final list item so it does not inherit the standard color/hover properties. Is it possible to target just the final menu item via CSS and override my Bootstraps CSS?
My CSS here:
.navbar-default .navbar-nav > li > a {
color: #ffffff;
font-family: "Fjalla One", sans-serif;
text-transform: uppercase;
font-size: 17px;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: #0091c1;
background-color: transparent;
}
use last-child
.navbar-nav li:last-child {
background: red;
}
see this js-fiddle.
http://jsfiddle.net/DTcHh/2690/
Yes, you can do this with the :last-child pseudo selector, like this:
.navbar-nav > li > a {
color: blue;
}
.navbar-nav > li:last-child > a {
color: green;
}
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Menu Item 1</li>
<li><a href="#">Menu Item 2</a></li>
<li><a href="#">Menu Item 3</a></li>
<li><a href="#">Change Color of this Menu Item</a></li>
</ul>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With