5

I just created a a navbar and a hover feature.But the problems are now that when I hover on HOME,BEDROOMS and CONTACT US,the color has no effect entirely from top to bottom on the navbar...but on the others(Eg: FACILITIES SERVICES) the color has full effect.

HTML

<nav class="navbar"> <div class="container"> <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> <span class="icon-bar"></span> </button> </div> <div class="collapse navbar-collapse" id="myNavbar"> <ul class="nav navbar-nav" style="padding-top:10px"> <li><span class="details"><strong>Phone</strong> </span><span class="contacts">021 913 0643</span></li> <br/> <span class="details"><strong>Email</strong> </span> <a class="contacts" href="#">[email protected] </a> </ul> <ul class="nav navbar-nav navbar-right"> <li class="active"><a href="#"><span ></span>Home</a></li> <li><a href="#"><span ></span> FACILITIES<br/> SERVICES</a></li> <li><a href="#">BEDROOMS</a></li> <li><a href="#">RATEs <br/> & BOOKINGS</a></li> <li><a href="#">SURROUNDING<br/> ATTRACTIONS</a></li> <li><a href="#">CONTACT US</a></li> </ul> </div> </div> </nav> 

CSS

.navbar{ padding: 0 px; background: #331a00; padding-left:12px; padding-right: 12px; border: 0px; } .navbar ul.navbar-right li a{ color: #ffffff; text-align: center; text-decoration: none; text-transform: uppercase; padding-top: 30px; padding-bottom: 20px; margin:0; text-align: center; } .navbar ul.navbar-right li a:hover{ background:#000000; } 

Check fiddle here

1

2 Answers 2

1

I have to used min-height: 90px; to .navbar-nav.navbar-right li and display property for .navbar-nav.navbar-right li and .navbar-nav.navbar-right li a.

To make text vertically middle use below css.

Updated CSS

.navbar{ background: #331a00; } .navbar ul li a{ color: #ffffff !important; text-transform: uppercase; } .navbar .navbar-default { background:none; border:0; } .navbar ul.navbar-right li a:hover{ background:#000000; } @media (min-width: 768px){ .navbar ul li a{ text-align:center; } .navbar-nav.navbar-right li{ display:table; min-height:90px; } .navbar-nav.navbar-right li a{ display:table-cell; vertical-align: middle; } } @media (max-width: 767px){ .navbar-nav.navbar-right li{ display:table; width:100%; min-height:60px; } .navbar-collapse{ max-height: inherit; } .navbar-nav.navbar-right li a{ display:table-cell; vertical-align: middle; } } 

Check Updated Fiddle

Sign up to request clarification or add additional context in comments.

9 Comments

Works perfectly for the the weight.The new challenge now is that the alignment is not perfect. Eg: The FACILITIES SERVICES is properly on the center,but the Home aligns to theFACILITIES SERVICES of being position a bit further down so it could be properly aligned to the center(top&bottom) between Facilities Services. Just to remember that FACILITIES SERVICES are not in the same line.
In small devices(when the navbar collapses), the same problem happens to the hover option but in this case is from left to right. Meaning that if I hover on HOME,only the little section will turn black. How can I make that to turn black entirely on the navbar from left to right?
It helps a lot.Is there a way that I can a give a unique size to the padding when I hover the lists? Because I can see that when I hover on HOME,it turns black yes,but the size of the same black section is smaller comparing to the one on the FACILITIES SERVICES.
Which size are you talking about??
Eg:When you hover on HOME it turns black all the way from left to right and obviously from TOP to BOTTOM around the HOME link. The same applies to other links. The problem is that as I hover each of those links and it keeps on turning black the size of the padding(TOP to BOTTOM ) is different for each link. Just to emphasize that am referring to that when the navbar is on the collapsing mode.
|
1

Surely this CSS code works perfectly:

 @import url('http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css'); .navbar{ background: #331a00; } .navbar ul li a{ color: #ffffff !important; text-transform: uppercase; } .navbar .navbar-default { background:none; border:0; } .navbar ul.navbar-right li a:hover{ background:#000000; } @media (min-width: 768px){ .navbar ul li a{ text-align:center; } .navbar-nav.navbar-right li{ display:table; min-height:90px; } .navbar-nav.navbar-right li a{ display:table-cell; vertical-align: middle; } } @media (max-width: 767px){ .navbar-nav.navbar-right li{ display:table; width:100%; min-height:60px; } .navbar-collapse{ max-height: inherit; } .navbar-nav.navbar-right li a{ display:table-cell; vertical-align: middle; } } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.