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...
Related
So I have this code:
.hoverlist12:hover #details {
display: block;
}
The thing is the list doesn't appear at all. If I change the hoverlist12 class with the ul, it works fine, but it appears when I hover on all the elements, and I want it to appear when I hover it only on the first "li". Usually, I have no problem doing this but now I just can't figure it out.
.navbar {
border-radius: 0;
max-height: 50px;
}
.navbar-default .navbar-nav > li > a,
.navbar-default .navbar-brand {
color: #ffffff;
}
.navbar-default .navbar-brand:hover {
color: #ffffff;
transform: scale(1.1);
}
.navbar-default .navbar-nav > li > a:focus,
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-brand:focus,
.navbar-default .navbar-brand:hover {
color: #ffffff;
}
.navbar-default .navbar-nav > li:focus,
.navbar-default .navbar-nav > li:hover {
background-color: rgba(0, 0, 0, 0.15);
}
nav {
font-family: "ITCErasStd-Medium";
}
.hiddeOnTop {
visibility: hidden;
}
.container-fluid {
padding-right: 3%;
padding-left: 3%;
display: inline-block;
width: 100%;
}
.navbar-default,
.container-fluid {
background-color: #be3c7a;
}
.nav > li > a {
font-size: 1.1em;
}
.navbar .facebook {
padding: 0;
margin-top: 7px;
}
.navbar .facebook:hover {
background: none;
transform: scale(1.1);
}
.navbar-brand,
.nav > li.active > a {
font-family: "ITCErasStd-Bold";
}
#details {
padding: 26px 30px;
display: none;
color: white;
z-index: 900;
font-size: 2rem;
list-style-type: none;
position: absolute;
margin-top: 50px;
background-color: #be3c7a;
}
.hoverlist12:hover #details {
display: block;
}
<nav class="mobile_nav">
<button type="button">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<ul class="nav-content">
<li>
<a href="htps://www.facebook.com" alt="facebook" class="facebook"
><img
src="./img/fb-icon.svg"
alt="fb-icon"
onerror="this.src='./img/fb-icon.png'"
/></a>
</li>
<!-- <li class="homelk">HOME</li> -->
<li class="homelk">
CE ESTE adadsadassssss
</li>
<li>INTREBARI FRECVENTE</li>
<li>PARTENERI</li>
<li>CONTACT</li>
<!-- <li><i class="fa fa-facebook-official"></i></li> -->
</ul>
</nav>
<!-- //////////////////////////// NAVBAR \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\-->
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button
type="button"
class="navbar-toggle"
data-toggle="collapse"
data-target="#myNavbar"
>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand navigate" href="#home"><span>HOssME</span></a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right dropdown">
<li class="hoverlist12">
CE ESTE USCACIUNEA
</li>
<ul id="details">
<li>Manifestari</li>
<li>Femeia activa</li>
<li>Maternitatea</li>
<li>Menopauza</li>
<li>Sub tratament</li>
</ul>
<li> DE CE HAYLO GYN </li>
<li> INTREBARI </li>
<li>CONTACT</li>
<li>
<a href="htps://www.facebook.com" alt="facebook" class="facebook"
><img
src="./img/fb-icon.svg"
alt="fb-icon"
s
onerror="this.src='./img/fb-icon.png'"
/></a>
</li>
<!-- <li><i class="fa fa-facebook-official"></i></li> -->
</ul>
</div>
</div>
</nav>
Use selector like this: .hoverlist12:hover ~ #details Because #details and .hoverlist12 elements are siblings or at same level. You can use this selector only .hoverlist12:hover #details when #details is a child element of .hoverlist12. So, please change your CSS code as I suggested OR Please change your structure like:
<li class="hoverlist12">
CE ESTE USCACIUNEA
<ul id="details">
<li>Manifestari</li>
<li>Femeia activa</li>
<li>Maternitatea</li>
<li>Menopauza</li>
<li>Sub tratament</li>
</ul>
</li>
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.
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 :)
I have created a custom height navbar with a large logo image and I'm sure I have missed something in the CSS because when the dropdown menu is clicked it jumps higher on the page until it is clicked a second time, and then the link works.
There is a "working" example at http://machadodesign.com/bootstrap/
Here is the CSS I have for the navbar
#media (min-width: 992px) {
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
min-height: 85px;
bottom: 0 ;
}
}
.navbar-nav li a {
padding-top: 30px;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: #333;
background-color: #e7e7e7;
}
.navbar-default .navbar-nav .active a {
background: #f8f8f8;
text-shadow: 0px 0px 9px rgba(144, 169, 210, 1) !important;
}
.dropdown .active {
text-shadow: 0px 0px 9px rgba(144, 169, 210, 1) !important;
}
.navbar-brand {
height: inherit;
padding: 5px 15px;
}
.navbar-brand a{
padding-top: 0 !important;
}
.navbar-brand img {
height: 50px
}
.dropdown li, .dropdown li:hover {
/* padding-top: 10px;*/
padding-bottom: 0px !important;
/* min-height: 40px;*/
}
.dropdown li a {
padding-top: 10px;
padding-bottom: 0px !important;
min-height: 40px;
}
.logo-tag {
font-size: 10px;
font-style: italic;
font-weight: 700;
line-height: 14px;
letter-spacing: 0.04em;
}
#media (min-width: 768px) {
.logo-tag {
font-size: 13px;
font-style: italic;
font-weight: 700;
line-height: 14px;
letter-spacing: 0.04em;
}
.navbar-brand img {
height: 58px
}
.navbar-brand {
height: inherit;
padding: 3px 15px;
}
}
Here is the HTML of the navbar as I have it.
<nav role="navigation" class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid social-bar hidden-xs">
<div class="container">
<div class="row">
<div class="col-sm-9">Questions? Need help? Call now: (866) 214-6128</div>
<div class="col-sm-3 text-right">
<ul class="list-inline">
<li><i class="fa fa-lg fa-facebook"></i></li>
<li><i class="fa fa-lg fa-twitter"></i></li>
<li><i class="fa fa-lg fa-google-plus"></i></li>
<li><i class="fa fa-lg fa-youtube"></i></li>
<li><i class="fa fa-lg fa-rss"></i></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" id="myNavbar" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<img src="images/logo.png"><span class="logo-tag">Customer and Class Management Made Easy!</span>
</div>
<!-- Collection of nav links and other content for toggling -->
<div id="navbarCollapse" class="collapse navbar-collapse navbar-right">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li class="dropdown">
Features <span class="caret"></span>
<ul class="dropdown-menu navbar-right">
<li>Features Overview</li>
<li>Easy Startup!</li>
<li>Easy to Use!</li>
<li>Easy to Customize!</li>
<li>Power-user Features</li>
<li>Multi-country</li>
<li>Lots of Add-ons</li>
</ul>
</li>
<li class="dropdown">
Try it Free <span class="caret"></span>
<ul class="dropdown-menu">
<li>Take a Test Drive</li>
<li>Get Started Today</li>
</ul>
</li>
<li>Pricing</li>
<li>Contact Us</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><i class="fa fa-lock"></i> Login</li>
</ul>
</div>
</div>
</nav>
Any help is greatly appreciated.
The problem is right at the top of your provided CSS:
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
min-height: 85px;
bottom: 0 ;
}
It only retains its min-height if it is hovered over or in focus, which is why the click is causing the jump (triggering focus). Change it to this:
.navbar-default .navbar-nav > li > a {
min-height: 85px;
bottom: 0 ;
}
I am trying to create a navbar using bootstrap.But the home icon in navbar is not showing properly.It is not in middle and not in parallel with other list.Please help me to solve this.
Problem:
HTML:
<nav class="navbar navbar-inverse">
<div class="container">
<div class="row">
<nav class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li>
<a href="#" class="navbar-brand text-center">
<span class="glyphicon glyphicon-home"></span>
</a>
</li>
<li class="active">
<a href="#">Avro keyboard<br/>
<small>For windows</small>
</a>
</li>
<li>
<a href="#">iAvro<br/>
<small>For Mac OS X</small>
</a>
</li>
<li>
<a href="#">ibus-avro<br/>
<small>for linux</small>
</a>
</li>
<li>
<a href="#">Bangla Fonts<br/>
<small>Unicode/ANSI fonts</small>
</a>
</li>
<li>
<a href="#">Others<br/>
<small>Misc goodies</small>
</a>
</li>
<li>
<a href="#">Blog<br/>
<small>Stay updated!</small>
</a>
</li>
<li>
<a href="#">Help and support<br/>
<small>Forum & Help files</small>
</a>
</li>
<li>
<a href="#">Developers<br/>
<small>repositories and resources</small>
</a>
</li>
</ul>
</nav>
</div>
</div>
</nav>
CSS:
li {
border-left: 1px solid;
border-top: 0px;
border-right: 1px solid;
border-bottom: 0px;
border-style: solid;
border-color: #545454;
}
a {
color: #FFFFFF !important;
}
small {
color: #C5C6C1;
font-style: italic;
}
You can apply any changes to the CSS rule below:
.navbar-inverse .navbar-brand .glyphicon{
padding: 5px 0 0 15px;
}
.navbar {
border-radius: 0;
}
.navbar-inverse .navbar-header .navbar-brand {
color: #FFFFFF;
}
.navbar-inverse .navbar-nav > li:first-child {
border: none;
padding-top: 10px;
}
.navbar-inverse .navbar-nav {
border-left: 1px solid #545454;
}
.navbar-inverse .navbar-nav > li {
border: none;
border-left: 1px solid #545454;
border-right: 1px solid #545454;
}
.navbar-inverse ul.navbar-nav > li > a {
color: #FFFFFF;
}
small {
color: #C5C6C1;
font-style: italic;
}
#media (min-width: 1200px) {
.navbar .navbar-nav {
display: inline-block;
float: none;
vertical-align: top;
}
.navbar .navbar-collapse {
text-align: center;
}
.navbar-inverse .navbar-header a {
display: none;
}
}
#media (max-width: 1200px) {
.navbar-inverse .navbar-nav > li:first-child {
display: none;
}
.navbar-inverse .navbar-nav {
border: none;
}
.navbar-inverse .navbar-brand {
line-height: 0;
}
.navbar-inverse .navbar-nav > li {
border: none;
}
.navbar-inverse .navbar-header {
float: none;
}
.navbar-inverse .navbar-left,
.navbar-right {
float: none !important;
}
.navbar-inverse .navbar-toggle {
display: block;
}
.navbar-inverse .navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.navbar-inverse .navbar-collapse.collapse {
display: none !important;
}
.navbar-inverse .navbar-nav {
float: none !important;
margin-top: 7.5px;
}
.navbar-inverse .navbar-nav > li {
float: none;
}
.navbar-inverse .navbar-nav > li > a {
padding-top: 10px;
padding-bottom: 10px;
}
.navbar-inverse .collapse.in {
display: block !important;
}
}
<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.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-inverse">
<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="#"> <span class="glyphicon glyphicon-home"></span>
</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> <a href="#"><span class="glyphicon glyphicon-home"></span>
</a>
</li>
<li class="active"> <a href="#">Avro keyboard<br/>
<small>For windows</small>
</a>
</li>
<li> <a href="#">iAvro<br/>
<small>For Mac OS X</small>
</a>
</li>
<li> <a href="#">ibus-avro<br/>
<small>for linux</small>
</a>
</li>
<li> <a href="#">Bangla Fonts<br/>
<small>Unicode/ANSI fonts</small>
</a>
</li>
<li> <a href="#">Others<br/>
<small>Misc goodies</small>
</a>
</li>
<li> <a href="#">Blog<br/>
<small>Stay updated!</small>
</a>
</li>
<li> <a href="#">Help and support<br/>
<small>Forum & Help files</small>
</a>
</li>
<li> <a href="#">Developers<br/>
<small>repositories and resources</small>
</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>