Skip to content Skip to sidebar Skip to footer

How To Change Bootstrap Navigation Menu Colors?

I want to change the color of the 'Home' 'Spin' 'Social Media' but no clue how. I spent a few days on figuring out how to change the navigation background but have no clue on the

Solution 1:

This is a relatively comprehensive breakdown of the navigation components and often changed properties. I would suggest using a custom class in your main navbar div (navbar-custom is used for this example) to avoid changing the base CSS directly.

/***Navbar Background Color, Border Removed ,Border Radius Sqaure***/.navbar.navbar-custom {
  background: #66ccff;
  border: none;
  border-radius: 0;
}
/***Link Color***/.navbar.navbar-custom.navbar-nav > li > a {
  color: #f00;
}
/***Link Color Hover Statr***/.navbar.navbar-custom.navbar-nav > li > a:hover {
  color: #ff0;
}
/***Link Background and Color Active State***/.navbar.navbar-custom.navbar-nav > .active,
.navbar.navbar-custom.navbar-nav > .active > a,
.navbar.navbar-custom.navbar-nav > .active > a:hover,
.navbar.navbar-custom.navbar-nav > .active > a:focus {
  background: #DBF022;
  color: #66ccff;
}
/***Navbar Brand Link Color***/.navbar.navbar-custom.navbar-brand {
  color: #f00;
}
/***Navbar Brand Link Color Hover State***/.navbar.navbar-custom.navbar-brand:hover {
  color: #ff0;
}
/***Dropdown Background Active State***/.navbar.navbar-custom.navli.dropdown.open > .dropdown-toggle,
.navbar.navbar-custom.navli.dropdown.active > .dropdown-toggle,
.navbar.navbar-custom.navli.dropdown.open.active > .dropdown-toggle {
  background: #DBF022;
  color: #f00;
}
/***Dropdown-menu Background Color***/.navbar.navbar-custom.dropdown-menu {
  background: #66ccff;
  border: none;
}
/***Dropdown-menu Color***/.navbar.navbar-custom.dropdown-menu > li > a {
  color: #f00;
}
/***Dropdown-menu Color Hover and Focus State***/.navbar.navbar-custom.dropdown-menu > li > a:hover,
.navbar.navbar-custom.dropdown-menu > li > a:focus {
  color: #ff0;
  background: #f00;
}
/***Toggle Button***/.navbar.navbar-custom.navbar-header.navbar-toggle {
  border-color: #f00;
}
/***Toggle Button Hover and Focus State***/.navbar.navbar-custom.navbar-header.navbar-toggle:hover,
.navbar.navbar-custom.navbar-header.navbar-toggle:focus {
  background: #f00;
  border: #f00;
}
/***Collapse Borders***/.navbar.navbar-custom.navbar-collapse {
  border: none;
}
@media (max-width: 767px) {
  .navbar.navbar-customli.dropdown.dropdown-menu > li > a {
    color: #f00;
  }
  /***Dropdown-menu Color Hover and Focus State***/.navbar.navbar-customli.dropdown.dropdown-menu > li > a:hover,
  .navbar.navbar-customli.dropdown.dropdown-menu > li > a:focus {
    color: #ff0;
    background: #f00;
  }
}
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script><linkhref="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"rel="stylesheet" /><navclass="navbar navbar-inverse navbar-custom"><divclass="container-fluid"><!-- Brand and toggle get grouped for better mobile display --><divclass="navbar-header"><buttontype="button"class="navbar-toggle collapsed"data-toggle="collapse"data-target="#bs-example-navbar-collapse-1"aria-expanded="false"><spanclass="sr-only">Toggle navigation</span><spanclass="icon-bar"></span><spanclass="icon-bar"></span><spanclass="icon-bar"></span></button><aclass="navbar-brand"href="#">Brand</a></div><!-- Collect the nav links, forms, and other content for toggling --><divclass="collapse navbar-collapse"id="bs-example-navbar-collapse-1"><ulclass="nav navbar-nav"><liclass="active"><ahref="#">Link <spanclass="sr-only">(current)</span></a></li><li><ahref="#">Link</a></li><liclass="dropdown"><ahref="#"class="dropdown-toggle"data-toggle="dropdown"role="button"aria-haspopup="true"aria-expanded="false">Dropdown <spanclass="caret"></span></a><ulclass="dropdown-menu"><li><ahref="#">Action</a></li><li><ahref="#">Another action</a></li><li><ahref="#">Something else here</a></li></ul></li></ul></div><!-- /.navbar-collapse --></div><!-- /.container-fluid --></nav>

Solution 2:

.navbar.nav > li > a

that is the target you are seeking!

Solution 3:

to customize use the below selectors...

(note, you won't need !important if your customizations are loaded after the bootstrap css, ie your <link href="..my-customizations.css" /> loaded after <link href="...cdn...bootstrap.min.css" />)

/* links */.navbar-inverse.navbar-nav>li>a {
  color: red!important;
}

/* active, focus or hover links */.navbar-inverse.navbar-nav>.active>a, 
.navbar-inverse.navbar-nav>.active>a:focus, 
.navbar-inverse.navbar-nav>.active>a:hover {
  color: red!important;
}

jsfiddle example

Post a Comment for "How To Change Bootstrap Navigation Menu Colors?"