How to remove the background of the collapse button when the mouse hover to the button. here is the picture. I really want to remove that white background when mouse hover to that button please help me. Im new to html and css and also to bootstrap.
Here is my html code
<nav class ="navbar navbar-default" role= "navigation">
<div class = "container">
<div class ="navbar-header">
<button type ="button" class="navbar-toggle" data-toggle="collapse" data-target="#nav-collapse">
<span class="icon-bar" ></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="nav-collapse">
<ul class="nav navbar-nav">
<li class="active">Students</li>
<li class="nav-divider"></li>
<li>Faculty</li>
<li class="nav-divider"></li>
<li>About us</li>
<li class="nav-divider"></li>
<li>Contact us</li>
<li class="nav-divider"></li>
</ul>
</div>
</div>
</nav>
Here is my css code.
#fot{ position:fixed;
bottom:0;
}
.navbar-default{
background-color:rgb(193,57,45);
}
.navbar .nav > li > a{
color:#ffe6e6;
}
.navbar .nav > li > a:hover{
color:#000000;
}
.navbar .nav .active > a{
background-color:rgb(193,57,45);
color:#000000;
}
.navbar .nav .active > a:hover{
background:none;
color:#fff;
}
.nav .nav-divider{
height: 50px;
margin: 0 10px;
border-right: 1px solid #a92419;
border-left: 1px solid #c1392d;
}
#media(max-width: 768px)
{
.nav .nav-divider{
height: 1px;
margin: 0 10px;
background-color:#a92419;
}
.navbar-default .navbar-toggle .icon-bar {
background-color: #fff;
margin:0 0 4px;
width: 25px;
height: 5px;
}
button.navbar-toggle{
background:none;
border:none;
color:#000;
}
.navbar-default .navbar-collapse, .navbar-default .navbar-form {
border-color: #a92419;
}
}
You need to specify the background-color for both hover as well as focus.
You can do that by adding this to your CSS:
.navbar-default .navbar-toggle:focus, .navbar-default .navbar-toggle:hover {
background: none;
}
Here's a jsFiddle with the above code: https://jsfiddle.net/AndrewL32/mowb6gcb/
use this css which works on hover
button.navbar-toggle:hover{
background:none;
/* other css as you requirment*/
}
This is the normal, straight forward way, using the psuedo class :hover to add a css style to items upon hovering the mouse over them
button.navbar-toggle {
background: #ccc; //a gray background as default
}
button.navbar-toggle:hover {
background: none; //no background when you hover over the button
}
Related
In my navigation links when I hover over a particular <li> the background color changes. That's what I want. But when I shift the mouse cursor to its child menu list (drop down content), the background color of the parent <li> changes to something else. I tried giving !important on its focus, before, after, active everything but nothing seems to work. When I hover on that particular <li> to get the sub menu the background color changes fine but when I move over to the sub menu its background color changes again. Also, please note that when I shift my cursor to the next <li> item its still working fine. The problem is occurring only when my cursor goes down to the dropdown menu. I am using Bootstrap v3.3.6.
CSS
#category-navi .cats-menu {
width: 100%;
background: rgba(0,0,0,0.6);
position: fixed;
margin-top: 60px;
z-index: 100;
border-top: 1px solid rgba(0,0,0,0.5);
}
.parent-menu .navbar-collapse {
padding-left: 0px;
}
.parent-menu .nav li > a:hover {
background-color: rgba(0,0,0,0.6);
color: #fff;
}
.parent-menu .nav li > a:after {
background-color: rgba(0,0,0,0.6);
color: #fff;
}
.mega-dropdown {
position: static !important;
}
.dropdown-toggle a:hover {
background-color: rgba(0,0,0,0.8) !important;
color: #fff;
}
.mega-dropdown-menu {
padding: 20px 0px;
width: 100%;
box-shadow: none;
-webkit-box-shadow: none;
}
.mega-dropdown-menu > li > ul {
padding: 0;
margin: 0;
}
.mega-dropdown-menu > li > ul > li {
list-style: none;
}
.mega-dropdown-menu > li > ul > li > a {
display: block;
color: #222;
padding: 3px 5px;
}
.mega-dropdown-menu > li ul > li > a:hover,
.mega-dropdown-menu > li ul > li > a:focus {
text-decoration: underline;
background-color: none !important;
}
.mega-dropdown-menu .dropdown-header {
font-size: 18px;
color: #ff3546;
padding: 5px 60px 5px 5px;
line-height: 30px;
}
.dropdown-toggle {
color: #fff;
}
.mega-dropdown ul {
margin-top: -1px !important;
margin-left: -1px !important;
border-top: none !important;
}
HTML
<section id="category-navi">
<div class="cats-menu" id="cats-menu">
<div class="container">
<div class="parent-menu">
<nav class="navbar">
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".js-navbar-collapse">
<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="collapse navbar-collapse js-navbar-collapse">
<ul class="nav navbar-nav">
{foreach from=$cats item=cat}
<li class="dropdown mega-dropdown">
{$cat.name} <span class="caret"></span>
<ul class="dropdown-menu mega-dropdown-menu">
{foreach from=$cat.categories item=subcat}
<li class="col-sm-3">
<ul>
<li class="dropdown-header">{$subcat.sc_name}</li>
{foreach from=$subcat.ccname item=childcat}
<li>{$childcat.cc_name}</li>
{/foreach}
</ul>
</li>
{/foreach}
</ul>
</li>
{/foreach}
</ul>
</div><!-- /.nav-collapse -->
</nav>
</div>
</div>
</div>
</section>
change: .parent-menu .nav li > a:hover
to: .parent-menu .nav li > .dropdown-toggle:hover
I'm creating a navbar using MaterializeCSS and I added some code to change the color of the items when hover. But, when I add a class "active" to the li I don't know how to change the background color and the text color of the navbar item.
<nav class="navbar-fixed">
<div class="nav-wrapper">
<a href="lobby.php" class="brand-logo center">
<img id="logo" src="images/logo.png"/>
</a>
<i class="material-icons">menu</i>
<ul class="left hide-on-med-and-down">
<li>Item1</li>
<li class="active">Item2</li>
<li>Item3</li>
</ul>
</div>
</nav>
My CSS:
nav.navbar-fixed {
background: white;
border: none;
box-shadow: none;
height: 70px;
}
.navbar-fixed .nav-wrapper {
background: white;
margin: 20px;
}
.navbar-fixed .nav-wrapper > ul > li > a {
color: #faa61a;
}
.navbar-fixed .nav-wrapper > ul > li > a:hover {
color: white;
}
.navbar-fixed .nav-wrapper > ul > li:hover {
background-color: #faa61a;
}
.navbar-fixed .nav-wrapper .brand-logo img {
height: 45px;
}
.navbar-fixed .nav-wrapper .button-collapse i {
color: black;
}
When I hover it, it's working OK, but when I set an item as active, it's using its default background-color and color.
Active is a class defined in materialise css.
nav ul li.active {
background-color: rgba(0, 0, 0, 0.1);
}
You can change the color or specify any other rule by overriding this class. If this doesn't help, Can you please put the code on fiddle and share the link?
.menu
{border-left: 1px solid #e9e9e9; border-right: 1px solid #e9e9e9; border-top: 1px solid #e9e9e9; overflow: hidden;}
.navbar {
}
.navbar > .active > a
{font-size: 14px; color: #3fbad8; font-family: 'open_sansbold'; background-image: none;
background:#f7f7f7; border: none; text-shadow: none; box-shadow: none;
}
.navbar > .active > a:hover{
box-shadow: none; background: #fff; color: #6f7678;
}
.navbar > li{
border-right: 1px solid #e9e9e9; float: left;display: block;position: relative; z-index:1000;}
.navbar > li>ul{display:none; position:relative;z-index:99}
.navbar > li > a { display:block;
color: #6f7678; padding: 25px; text-shadow: none; font-family: 'open_sansbold';
}
.navbar > li > a:hover{
background: #f7f7f7; color: #3fbad8;
}
.navbar > li:hover ul{display:block; postion:absolute;}
.navbar > li:hover li{float:none;}
.navbar . > li:hover li a:hover{background: #f7f7f7; color: #3fbad8;
}
#sub{
z-index:3;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
<div class="menu">
<div class="navbar">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<i class="fw-icon-th-list"></i>
</a>
<div>
<ul class="nav">
<li class="active">Home</li>
<li>About</li>
<li>Services
<ul class="nav"> <li>Printer Service</li>
<li>Computer Support</li>
<li>Email Support</li>
<li>Virus Support</li>
</ul></li>
<li>Testinominals</li>
<li>Price</li>
<li>Contact</li>
</ul>
<div runat="server" class="search-form">
Call Now +1-xxxxxxxxx
</div>
</div>
</div>
</div>
<!-- Menu ends -->
I have changed the position: relative; to position: absolute; however now the drop down goes back to the slide show. I tired a lot to fix this issue still I am unable to do it. Please guide me some one in a right way.
Add this
.menu{
position:absolute;
z-index:1000; //can be any number, but should be high enough to ensure it remains on top
}
It will take the menu out of the normal stacking order - allowing its contents to also be free of the normal DOM flow. That way when you open it, it will sit above the page content without pushing it down.
You will have to add margin to the top of your main content section equal to the height of your closed nav bar so that the content is not hidden behind the nav. You also need to apply the z-index to ensure that it remains on top of any other absolutely positioned elements on the page.
How can i change the color of the collapse button there? and the white lines like the divider. here is the picture. Can someone help me? im new to css,bootstrap and html so please help me. or give me some ideas.
Here is my code.
<nav class ="navbar navbar-default" role= "navigation">
<div class = "container">
<div class ="navbar-header">
<button type ="button" class="navbar-toggle" data-toggle="collapse" data-target="#nav-collapse">
<span class="icon-bar" ></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="nav-collapse">
<ul class="nav navbar-nav">
<li class="active">Students</li>
<li class="nav-divider"></li>
<li>Faculty</li>
<li class="nav-divider"></li>
<li>About us</li>
<li class="nav-divider"></li>
<li>Contact us</li>
<li class="nav-divider"></li>
</ul>
</div>
</div>
</nav>
Here is my css.
#fot{ position:fixed;
bottom:0;
}
.navbar-default{
background-color:rgb(193,57,45);
}
.navbar .nav > li > a{
color:#ffe6e6;
}
.navbar .nav > li > a:hover{
color:#000000;
}
.navbar .nav .active > a{
background-color:rgb(193,57,45);
color:#000000;
}
.navbar .nav .active > a:hover{
background:none;
color:#fff;
}
.nav .nav-divider{
height: 50px;
margin: 0 10px;
border-right: 1px solid #a92419;
border-left: 1px solid #c1392d;
}
#media(max-width: 768px)
{.nav .nav-divider{
height: 1px;
margin: 0 10px;
background-color:#a92419;
}
.navbar-default .navbar-toggle .icon-bar {
background-color: #fff;
margin:0 0 4px;
width: 25px;
height: 5px;
}
I guess this is what you are looking for:
.icon-bar
{
background:green !important; /*Whatever colour you want for icon lines*/
}
.navbar-toggle
{
background:yellow !important; /*Whatever colour you want for background */
}
In the CSS !important forces to apply property aside it over actual properties of Bootstrap CSS.
Update: In your CSS ADD Following code:
.navbar-default .navbar-collapse, .navbar-default .navbar-form {
border-color: darkblue; /* Whatever Colour you want */
}
Yes ofcourse...just define some css on button class like this
CSS
button.navbar-toggle{
background:none;
border:none;
color:#000;
// and so on according to what style u want...
}
button.navbar-toggle span{
background:#000;/*change accordingly*/
// these span are for white line you can edit the lines in this css
}
I've been searching for a few hours on this and poured over the bootstrap code to no avail so here I am! I set my navbar to collapse at 991px and, once viewed, the list elements have the background color I wanted, but when you hover over them there's apparently a transparent margin for each list element. How would I get rid of this margin, i've been messing with navbar-nav li a and my links in the navbar are H5s so also navbar-nav li a H5. The last list element is a dropdown link and in the media query when clicked it remains as if hovered over so I'm assuming there's a focus tag with it I just can't think exactly how to fix these two things (still very new to CSS/Bootstrap if you didn't know). Here is the HTML below and any help is very much appreciated!
<nav class="navbar navbar-default navbar-fixed-top">
<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="#topFixedNavbar1" 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="#">Logo</a></div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="topFixedNavbar1">
<ul class="nav navbar-nav navbar-right links">
<li><h5>How We Work</h5></li>
<li><h5>Abous Us</h5></li>
<li class="dropdown"><h5>Course Subjects</h5><span class="caret"></span>
<ul class="dropdown-menu dropdown-menu-right">
<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 -->
And here is the CSS (I included the whole file, but I'm pretty sure the problem will have to do with the media query):
body{
padding-top: 120px;
background-color:#34A0CD;
}
.navbar-default{
height:120px;
}
.navbar-header, .navbar-brand{
height:120px;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
#topFixedNavbar1{
height:120px;
}
.links{
height:120px;
}
.navbar-nav li a h5{
line-height:80px;
}
.dropdown li a {
line-height:30px;
}
#media (max-width: 991px) {
.dropdown li a{
line-height:30px;
}
.collapse.navbar-collapse{
width:100%;
}
.links li a{
width:100%;
}
.navbar-header {
float: none;
}
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.navbar-collapse.in {
overflow-y: visible;
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
}
.navbar-nav>li {
float: none;
}
.navbar-nav li a h5{
line-height: 30px;
background-color: gray;
color: #F1E9E9;
}
.navbar-nav li a{
background-color:gray;
width:100%;
}
.navbar-text {
float: none;
margin: 15px 0;
}
/* since 3.1.0 */
.navbar-collapse.collapse.in {
display: block!important;
}
.collapsing {
overflow: hidden!important;
}
}
I forked into a Fiddle that was created with Bootstrap in mind and threw in your code so I think I might have reproduced the issue. The problem didn't seem to be margins at all but background color that is set to transparent on hover/focus by default in Bootstrap.
.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus {
color: rgb(51, 51, 51);
background-color: transparent;
}
I tested out just a simple modification to this with to override the default styles and it seemed to work.
.navbar-collapse .navbar-nav>li>a:hover,
.navbar-collapse .navbar-nav>li>a:focus{
background-color: gray;
}
Here's a demo
Obviously you can modify that however, but that should put you on the right track.