Change bootstrap active menu item color [closed] - html

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I would like to change the background color of active element in menu. I've tried a lot of solutions but i still can't do this.
Menu and css:
/* MAIN SITE NAVIGATION */
.navbar.navbar-default {
font-size: 14px;
background-color: #FFFFFF;
border-bottom-width: 0px;
}
.navbar.navbar-default .navbar-nav {
background-color: #FFFFFF;
}
.navbar.navbar-default .navbar-nav>li>a {
color: #323232;
background-color: #FFFFFF;
text-transform: uppercase;
font-weight: 700;
letter-spacing: 1px;
}
.navbar.navbar-default .navbar-nav>li>a:hover,
.navbar.navbar-default .navbar-nav>li>a:focus {
color: #50A0FF;
background-color: #FFFFFF;
}
.navbar.navbar-default .navbar-nav>.active>a,
.navbar.navbar-default .navbar-nav>.active>a:hover,
.navbar.navbar-default .navbar-nav>.active>a:focus {
color: #50A0FF;
background-color: #FFFFFF;
}
.navbar.navbar-default .navbar-nav li .active {
background-color: red !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Pokaż MENU</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">Home
</li>
<li>About
</li>
<li>Contact
</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li>Separated link
</li>
<li>One more separated link
</li>
</ul>
</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</nav>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
Menu photo
i hope somebody will help me. ps sorry for my english :)

You are already doing that in your example. The problem is you are adding a while #ffffff background. Just change it to a different one.
This is your class sample
.navbar-default .navbar-nav>.active>a,
.navbar-default .navbar-nav>.active>a:hover,
.navbar-default .navbar-nav>.active>a:focus {
color: #50A0FF;
background-color: #FFFFFF; // change this to some color other than white
}
you also need to add this style in your style.css
.navbar-default .navbar-nav>.active>a, .navbar-default .navbar-nav>.open>a {
background-image: initial;
}
/* MAIN SITE NAVIGATION */
.navbar-default {
font-size: 14px;
background-color: #FFFFFF;
border-bottom-width: 0px;
}
.navbar-default .navbar-nav{
background-color: #FFFFFF;
}
.navbar-default .navbar-nav>li>a {
color: #323232;
background-color: #FFFFFF;
text-transform: uppercase;
font-weight: 700;
letter-spacing: 1px;
}
.navbar-default .navbar-nav>li>a:hover,
.navbar-default .navbar-nav>li>a:focus {
color: #50A0FF;
background-color: #FFFFFF;
}
.navbar-default .navbar-nav>.active>a,
.navbar-default .navbar-nav>.active>a:hover,
.navbar-default .navbar-nav>.active>a:focus {
color: #ffffff;
background-color: #000000;
}
.navbar-default .navbar-nav li .active {
background-color: red !important;
}
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Pokaż MENU</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>

Add this to your css:
.navbar-default .navbar-nav>.active>a,
.navbar-default .navbar-nav>.active>a:hover,
.navbar-default .navbar-nav>.active>a:focus {
color: #50A0FF;
background-color: #ebebeb !important;
display:block;
}

Try using following for your elements you want to change background color
.active a{
background-color: green !important;
}

Guys i've removed this line
<link rel="stylesheet" href="css/bootstrap-theme.min.css"/>
and now it is working :)

Related

Font-Awesome Icon Hover Issue

I have made a menu with Bootstrap and FontAwesome. I want to change the color of all the social media icons to their original colors. Below is the snippet:
HTML
<nav class="navbar navbar-fixed-top" style="border-top:2px solid #CC0033;border-bottom:2px solid #CC0033;">
<div class="container">
<div class="navbar-header">
<button aria-controls="navbar" aria-expanded="false" data-target="#navbar" data-toggle="collapse" class="navbar-toggle collapsed" type="button">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!--<div class="navbar-collapse collapse" id="navbar">-->
<div class="navbar-collapse collapse" id="navbar">
<ul class="nav navbar-nav navbar-left">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
<li class="dropdown">
<a aria-expanded="true" aria-haspopup="true" role="button" data-toggle="dropdown" class="dropdown-toggle" href="#">Dropdown</a>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider" role="separator"></li>
<li class="dropdown-header">Nav header</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><i class="fa fa-facebook-square social-icon"></i></li>
<li><i class="fa fa-twitter-square social-icon"></i></li>
<li><i class="fa fa-instagram social-icon"></i></li>
<li><i class="fa fa-pinterest-square social-icon"></i></li>
<li><i class="fa fa-youtube-square social-icon"></i></li>
<li><i class="fa fa-google-plus-square social-icon"></i></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
CSS
.navbar .navbar-nav > li
{
border: 0px !important;
}
.navbar .navbar-nav > li > a
{
color: #CC0033 !important;
font-family: 'Open Sans', sans-serif;
font-weight: bold;
font-size: 16px;
}
.navbar .navbar-nav > li > a:hover
{
color: #FFFFFF !important;
font-family: 'Open Sans', sans-serif;
font-weight: bold;
font-size: 16px;
background-color: #CC0033 !important;
}
.fa { font-family: 'FontAwesome' !important; }
.social-icon
{
color: #CC0033 !important;
font-size:25px !important;
}
.navbar .navbar-nav > li > a.twitter:hover
{
color: #00ACED !important;
}
Here is a non-working Demo
On hover the icon shall display like this:
For hover I have put the following CSS:
.navbar .navbar-nav > li > a.twitter:hover
{
color: #00ACED !important;
}
How can I achieve the same? Any help will be appreciated.
also try this
.navbar .navbar-right > li > a:hover{
color: #fff !important;
}
.navbar .navbar-right > li > a:hover .fa{
color: #fff !important;
}
Just remove the following code:
.navbar .navbar-nav > li > a:hover {
/* background-color: #CC0033 !important; */
}
The background-color is over shadowing the color of your font awesome icons, hence they are not visible on hover.
Instead if you want to change the color of your font awesome icons on hover use the following code:
.navbar .navbar-nav > li > a:hover > i {
color: #00abf1 !important;
}
EDIT
To change the background-color of the li to white, just remove the following code:
nav > li > a:hover {
/* background-color: #eee; */
}
You can achieve the desired effect by changing these two lines--
.navbar .navbar-nav > li > a:hover > i {
color: #00abf1 !important;
}
.navbar .navbar-nav > li > a:hover {
background-color: white !important;
}
In this way you can change the background-color of li to white.
.navbar .navbar-nav > li
{
border: 0px;
}
.navbar .navbar-nav > li > a
{
color: #CC0033;
font-family: 'Open Sans', sans-serif;
font-weight: bold;
font-size: 16px;
}
.navbar .navbar-nav > li > a:hover
{
color: #FFFFFF;
font-family: 'Open Sans', sans-serif;
font-weight: bold;
font-size: 16px;
background-color: #CC0033 !important;
}
.fa { font-family: 'FontAwesome' !important; }
.social-icon
{
color: #CC0033;
font-size:25px;
}
.navbar .navbar-nav > li > a:hover > i {
color: #00abf1 !important;
}
.navbar .navbar-nav > li > a:hover {
background-color: white !important;
}
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style type="text/css">
</style>
<script type="text/javascript">
</script>
</head>
<body>
<nav class="navbar navbar-fixed-top" style="border-top:2px solid #CC0033;border-bottom:2px solid #CC0033;">
<div class="container">
<div class="navbar-header">
<button aria-controls="navbar" aria-expanded="false" data-target="#navbar" data-toggle="collapse" class="navbar-toggle collapsed" type="button">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!--<div class="navbar-collapse collapse" id="navbar">-->
<div class="navbar-collapse collapse" id="navbar">
<ul class="nav navbar-nav navbar-left">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
<li class="dropdown">
<a aria-expanded="true" aria-haspopup="true" role="button" data-toggle="dropdown" class="dropdown-toggle" href="#">Dropdown</a>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider" role="separator"></li>
<li class="dropdown-header">Nav header</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><i class="fa fa-facebook-square social-icon"></i></li>
<li><i class="fa fa-twitter-square social-icon"></i></li>
<li><i class="fa fa-instagram social-icon"></i></li>
<li><i class="fa fa-pinterest-square social-icon"></i></li>
<li><i class="fa fa-youtube-square social-icon"></i></li>
<li><i class="fa fa-google-plus-square social-icon"></i></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</body>
</html>
Hope this helps!
If you replace this code:
.navbar .navbar-nav > li > a.twitter:hover
{
color: #00ACED !important;
}
With this:
.navbar .navbar-nav li a:hover > .fa-twitter-square { color: #00ACED !important; }
Than it should working, good luck!
Simply replace this
.navbar .navbar-nav > li > a:hover
{
color: #FFFFFF !important;
font-family: 'Open Sans', sans-serif;
font-weight: bold;
font-size: 16px;
background-color: #CC0033 !important;
color: #00aced
}
by this
.navbar .navbar-nav > li > a:hover
{
color: #FFFFFF !important;
font-family: 'Open Sans', sans-serif;
font-weight: bold;
font-size: 16px;
background-color: #CC0033;
color: #00aced
}
and add this
.navbar .navbar-right > li > a:hover{
background-color: #fff
}
.navbar .navbar-right > li > a.twitter:hover i{
color: #00aced !important;
}
All the best :)
Add this to your css code:
.social-icon:hover {
color: white!important;
}
Works for me that way...

How do I remove this background when hovering over navigation bar links?

There's this ugly gray color background when I over a link in the navigation bar.
How can I remove this gray background. The links should remain red and when hovered over, it should have been yellow on the overall black background but there's a gray background over that link. Also in the pills. I think the background appears whenever it's over something that is associated with 'nav' word cause other links look fine. Only the navigation bar and the pills cause its css is nav-pills apparently. Attaching images of what happens when I hover over it.
p.s - adding dot instead of.com because I have less than 10 reputation and cannot post more than 2 links.
http://i.imgur.com/rw8qvXP.jpg
http://i.imgur.com/56KoD1z.jpg
#mainNav .container{
padding:0
}
#mainNav .container .navbar-brand{
color:#fed136;font-family:"Kaushan Script","Helvetica Neue",Helvetica,Arial,cursive
}
#mainNav .container .navbar-brand.active,#mainNav .container .navbar-brand:active,#mainNav .container .navbar-brand:focus,#mainNav .container .navbar-brand:hover{
color:#fec503
}
#mainNav .container .btn-toggle{
padding:.75em;font-size:80%
}
#mainNav .container .navbar-nav .nav-item .nav-link{
font-size:90%;padding:.75em 0;font-family:Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;text-transform:uppercase;font-weight:400;letter-spacing:1px;color:red
}
#mainNav .container .navbar-nav .nav-item .nav-link.active,#mainNav .container .navbar-nav .nav-item .nav-link:hover{
color:#fed136
}
#media (min-width:768px){
#mainNav{
background-color:transparent;padding:25px 0;-webkit-transition:padding .3s;-moz-transition:padding .3s;transition:padding .3s;border:none
}
#mainNav .navbar-brand{
font-size:1.75em;-webkit-transition:all .3s;-moz-transition:all .3s;transition:all .3s
}
#mainNav .navbar-nav .nav-item .nav-link{
padding:1.2em .4em!important
}
#mainNav.navbar-shrink{
background-color:#222;padding:5px 0
}
#mainNav.navbar-shrink .navbar-brand{
padding:.65em 0;font-size:1.25em
}
}
<!-- Navigation -->
<nav id="mainNav" class="navbar navbar-fixed-top">
<div class="container">
<a class="navbar-brand page-scroll" href="#page-top">Demo</a>
<button class="btn btn-primary btn-toggle hidden-md-up float-xs-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">Menu <i class="fa fa-bars"></i></button>
<!-- Navigation Bar List Contents -->
<div class="clearfix hidden-md-up"></div>
<div class="collapse navbar-toggleable-sm" id="navbarResponsive">
<ul class="nav navbar-nav float-md-right">
<li class="nav-item">
<a class="nav-link page-scroll" href="#about">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link page-scroll" href="#sample">Sample Article</a>
</li>
<li class="nav-item">
<a class="nav-link page-scroll" href="#topics">Topics</a>
</li>
<li class="nav-item">
<a class="nav-link page-scroll" href="#whyus">Why Choose Us</a>
</li>
<li class="nav-item">
<a class="nav-link page-scroll" href="#contact">Contact</a>
</li>
<li>
Order now
</li>
</ul>
</div>
</div>
</nav>
It's because of Bootstrap CSS code. There is this code on hover:
.nav > li > a:focus, .nav > li > a:hover {
text-decoration: none;
background-color: #eee;
}
Remove the background color and it should do the trick.
In the next working snippet I set it to transparent by strengthening the selector:
.container .nav > li > a:focus,
.container .nav > li > a:hover {
text-decoration: none;
background-color: transparent;
}
#mainNav .container {
padding: 0
}
#mainNav .container .navbar-brand {
color: #fed136;
font-family: "Kaushan Script", "Helvetica Neue", Helvetica, Arial, cursive
}
#mainNav .container .navbar-brand.active,
#mainNav .container .navbar-brand:active,
#mainNav .container .navbar-brand:focus,
#mainNav .container .navbar-brand:hover {
color: #fec503
}
#mainNav .container .btn-toggle {
padding: .75em;
font-size: 80%
}
#mainNav .container .navbar-nav .nav-item .nav-link {
font-size: 90%;
padding: .75em 0;
font-family: Montserrat, "Helvetica Neue", Helvetica, Arial, sans-serif;
text-transform: uppercase;
font-weight: 400;
letter-spacing: 1px;
color: red
}
#mainNav .container .navbar-nav .nav-item .nav-link.active,
#mainNav .container .navbar-nav .nav-item .nav-link:hover {
color: #fed136
}
#media (min-width: 768px) {
#mainNav {
background-color: transparent;
padding: 25px 0;
-webkit-transition: padding .3s;
-moz-transition: padding .3s;
transition: padding .3s;
border: none
}
#mainNav .navbar-brand {
font-size: 1.75em;
-webkit-transition: all .3s;
-moz-transition: all .3s;
transition: all .3s
}
#mainNav .navbar-nav .nav-item .nav-link {
padding: 1.2em .4em!important
}
#mainNav.navbar-shrink {
background-color: #f00;
padding: 5px 0
}
#mainNav.navbar-shrink .navbar-brand {
padding: .65em 0;
font-size: 1.25em
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<!-- Navigation -->
<nav id="mainNav" class="navbar navbar-fixed-top">
<div class="container">
<a class="navbar-brand page-scroll" href="#page-top">Demo</a>
<button class="btn btn-primary btn-toggle hidden-md-up float-xs-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">Menu <i class="fa fa-bars"></i>
</button>
<!-- Navigation Bar List Contents -->
<div class="clearfix hidden-md-up"></div>
<div class="collapse navbar-toggleable-sm" id="navbarResponsive">
<ul class="nav navbar-nav float-md-right">
<li class="nav-item">
<a class="nav-link page-scroll" href="#about">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link page-scroll" href="#sample">Sample Article</a>
</li>
<li class="nav-item">
<a class="nav-link page-scroll" href="#topics">Topics</a>
</li>
<li class="nav-item">
<a class="nav-link page-scroll" href="#whyus">Why Choose Us</a>
</li>
<li class="nav-item">
<a class="nav-link page-scroll" href="#contact">Contact</a>
</li>
<li>
Order now
</li>
</ul>
</div>
</div>
</nav>
The simple way that you can do it is to open the page with firefox or chrome Browser and right click the portion that you want there a pop-up appear choose Inspect Element there a bunch of code appears.
On that left side shows the HTML and the right side part shows the css there you can change and see the difference as a live one.
Important thing is that copy the code form the part that you change and paste it in your code then only it works.

Getting rid of thin separating line above Navbar, Bootstrap3

I'm using Bootstrap 3 for my website. I have the usual .navbar on the page, and it works well, except for one thing that's out of my fashion. There's like a little dividing line between the .navbar-collapse and .navbar-header when the screen shrinks to the hamburger menu. I've boldened it in the pic.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<title>Stuson.com</title>
<meta name="description" content="Stuson.com is a social media platform for students, by students.">
<meta name="author" content="Stuson Dev Team">
<link href="https://fonts.googleapis.com/css?family=PT+Sans|Roboto" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="css\essentials.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>Link</li>
<li>Link</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li>Separated link</li>
<li role="separator" class="divider"></li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-left" role="form">
<div class="form-group">
<input type="text" class="form-control hidden-xs" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
<span class="hidden-lg hidden-md">Search</span>
</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li>Link</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<script src="http://code.jquery.com/jquery-3.1.1.js" integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="js/essentials.js"></script>
</body>
</html>
CSS
#noBorder {
border-style: none;
border-radius: 0;
}
#transparent {
background-color: transparent;
}
body {
font-family: "PT Sans", sans-serif;
font-weight: 300;
}
.navbar {
border-style: none;
border-radius: 0;
background-color: #38ba7d;
}
.navbar .navbar-header {
border-style: none;
border-radius: 0;
}
.navbar .navbar-header > .navbar-toggle,
.navbar .navbar-header .navbar-toggle:hover,
.navbar .navbar-header .navbar-toggle:focus {
border-style: none;
border-radius: 0;
background-color: transparent;
}
.navbar .navbar-header .navbar-brand {
color: #fff;
}
.navbar .navbar-collapse {
border-style: none;
border-radius: 0;
}
.navbar .navbar-collapse ul li > a {
color: #fff;
}
.navbar .navbar-collapse form {
display: flex;
flex-direction: row;
border-style: none;
border-radius: 0;
}
.navbar .navbar-collapse form input {
width: 250px;
}
#media (max-width: 786px) {
.navbar .navbar-collapse form input {
width: 10px;
}
}
.navbar .navbar-collapse form .btn {
background-color: transparent;
border-style: none;
border-radius: 0;
}
How can I avoid this? I've tried using border: none on both .navbar-collapse and .navbar-header, but to no avail.
Actually the 'border' is caused by a box-shadow, so add this:
.navbar .navbar-collapse{
box-shadow:none;
}
You can use this CSS code snippet:
#media (max-width: 768px) {
.navbar-default .navbar-collapse, .navbar-default .navbar-form {
border: 0;
}
}
Setting .navbar-default or .navbar-inverse to 0 should do the trick.
.navbar-default {
border: 0;
}

Changing Bootstrap NavBar color

I was attempting to change the navbar color in Bootstrap, but it was unsuccessful. The navbar just stays the same as if I never added the CSS or custom styling.
I added the custom CSS into my custom CSS file, style.css. Below is the entire contents of the style.css file.
You can also view my HTML below, which is the contents of index.htm which regard the navbar and styling.
Note: I'm using bootstrap from the latest version located at http://getbootstrap.com; not previous versions (Example: Twitter Bootstrap)
style.css
/* Custom Styling */
/* Core Styling */
body {
font-famliy: Helvetica, sans-serif;
font-size 14px;
line-height: 1.42857143;
color: #333;
}
/* Navbar Styling */
/* navbar */
.navbar-default {
background-color: #14a3ff;
border-color: #1495fe;
}
.navbar-default .navbar-brand {
color: #ecf0f1;
}
.navbar-default .navbar-brand:hover, .navbar-default .navbar-brand:focus {
color: #ecf0f1;
}
.navbar-default .navbar-text {
color: #ecf0f1;
}
.navbar-default .navbar-nav > li > a {
color: #ecf0f1;
}
.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus {
color: #ecf0f1;
}
.navbar-default .navbar-nav > .active > a, .navbar-default .navbar-nav > .active > a:hover, .navbar-default .navbar-nav > .active > a:focus {
color: #ecf0f1;
background-color: #1495fe;
}
.navbar-default .navbar-nav > .open > a, .navbar-default .navbar-nav > .open > a:hover, .navbar-default .navbar-nav > .open > a:focus {
color: #ecf0f1;
background-color: #1495fe;
}
.navbar-default .navbar-toggle {
border-color: #1495fe;
}
.navbar-default .navbar-toggle:hover, .navbar-default .navbar-toggle:focus {
background-color: #1495fe;
}
.navbar-default .navbar-toggle .icon-bar {
background-color: #ecf0f1;
}
.navbar-default .navbar-collapse,
.navbar-default .navbar-form {
border-color: #ecf0f1;
}
.navbar-default .navbar-link {
color: #ecf0f1;
}
.navbar-default .navbar-link:hover {
color: #ecf0f1;
}
#media (max-width: 767px) {
.navbar-default .navbar-nav .open .dropdown-menu > li > a {
color: #ecf0f1;
}
.navbar-default .navbar-nav .open .dropdown-menu > li > a:hover, .navbar-default .navbar-nav .open .dropdown-menu > li > a:focus {
color: #ecf0f1;
}
.navbar-default .navbar-nav .open .dropdown-menu > .active > a, .navbar-default .navbar-nav .open .dropdown-menu > .active > a:hover, .navbar-default .navbar-nav .open .dropdown-menu > .active > a:focus {
color: #ecf0f1;
background-color: #1495fe;
}
}
index.htm
index.htm > styling (head)
<!-- Custom Styling -->
<link rel="stylesheet" href="css/style.css" />
<!-- <link rel="stylesheet" href="css/bootstrap.min.css" /> -->
<link rel="stylesheet" href="css/bootstrap.css" />
<link rel="stylesheet" href="css/font-awesome.min.css" />
index.htm > navbar & js (out of head)
<!-- Navbar -->
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">Link <span class="sr-only">(current)</span></li>
<li>Link</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
<li class="divider"></li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li>Link</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="js/bootstrap.js"></script>
I found the solution to the issue that was occurring. It was quite a simple issue actually.
The issue was that I was adding the bootstrap CSS in the HTML after the custom css was added.
So it should've been:
<head>
<!-- Custom Styling -->
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/style.css" />
</head>
Thanks for all the help.
As of Bootstrap 4 you can easily change the colour of a navbar background with the 'bg' class. A few examples are below:
<nav class="navbar navbar-expand-lg navbar-light bg-white sticky-top">
<a class="navbar-brand" href="#">
<div class="collapse navbar-collapse">
<img src="#" alt="Logo" style="width:300px;">
</a>
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
</ul>
</nav>
It is a basic navbar which expands on larger devices, collapses on smaller ones, and sticks to the top of the page. The "bg-white" element changes the background colour of the navbar from the default grey colour to white. A few more examples are:
bg-primary
bg-secondary
bg-success
bg-danger
bg-warning
bg-info
bg-light
bg-dark
bg-white
Bootstrap NavBar Generator is what you need. It is a little bit tricky when you use the CSS generated.
In case you find that after you insert the generated stylesheet the NavBar does not change at all.
Please including the following was what made it possible to change the navbar color:
.navbar{
background-image: none;
}
Hope this is helpful. :D

Changing BootStrap Nav Pills Dropdown Link Hover Background Color on Navbar

I'm building a site and I am utilising the Bootstrap framework as it saves me a lot of development time.
The Issue
I have a collection of links a couple of dropdown links and the rest are just regular links.
I have managed to successfully change the hover state of the links without a dropdown menu by giving them a different background colour.
But the problem I am having is that I cannot change the background colour of the links that have a dropdown menu. I don't mean the actual background colour of the dropdown menu but the nav-pill link on the navbar.
I have been trying to resolve the issue in my custom styles stylesheet (styles.css) using the following CSS code
.nav-pills {
padding-top: 20px;
}
.nav-pills > li > a {
font-size: 15px;
color: #37404e;
border-radius: 5px 5px 0 0;
padding: 10px;
}
.nav-pills > li > a:hover {
background-color: #418bca;
color: #fff;
}
/* --- dropdown-menu --- */
.dropdown-menu {
margin-top: -5px;
}
.dropdown-menu > li {
font-size: 15px;
}
.dropdown-menu > li > a {
transition: .3s;
-webkit-transition: .3s;
-moz-transition: .3s;
}
.dropdown-menu > li > a:hover {
background-color: #ff6347;
color: #fff;
}
.dropdown-header {
color: #418bca;
}
I just can't seem to find a fix for this.
Any advice on how this can be fixed would be greatly appreciated!
Try this:
DEMO:
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav nav-pills">
<li class="active">Link</li>
<li>Link</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
<li class="divider"></li>
<li>One more separated link</li>
</ul>
</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
<li class="divider"></li>
<li>One more separated link</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
I used these as my styles:
.navbar-default .navbar-nav .nav > li > a:hover,
.navbar-default .navbar-nav .nav > li.dropdown.active.open > a:hover,
.navbar-default .navbar-nav .nav > li.dropdown.active.open > ul.dropdown-menu > li > a:hover,
.navbar-default .navbar-nav .nav > li.dropdown.open > a:hover,
.navbar-default .navbar-nav .nav > li.dropdown.open > ul.dropdown-menu a:hover,
.navbar-default .navbar-nav .nav > li.dropdown.open > a,
.navbar-default .navbar-nav .nav > li.dropdown.open > ul.dropdown-menu a,
{
background-color: #fff;
border-color: #fff;
}
You may need to change the selectors before the first > depending on your structure of your HTML.