gabbianella
gabbianella

Reputation: 1

Bootstrap navbar-right styling

I have this navbar, just the original one, I only added my menu. I want the navbar-right (language options) to have a smaller font-size than the main navbar.

<nav class="navbar navbar-default">
        <div class="container-fluid ">
            <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 titolo" href="index.html">Anna Lisa Di Vaio<small>fotografo</small></a>
            </div>
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav nav_grassetto">
                    <li class="active"><a href="index.html">HOME <span class="sr-only">(current)</span></a></li> 
                    <li ><a href="gallery.html">GALLERY</a></li>
                    <li><a href="/blog">BLOG</a></li>
                    <li><a href="contact.html">CONTACT</a></li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li class="active"><a href="#">IT</a></li>
                    <li ><a href="#">EN</a></li>
                    <li><a href="#">中文</a></li>
                </ul>
            </div>         
        </div>
    </nav>

CSS (my modified css AFTER the original bootstrap CSS)

<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css">   
<link href="css/stylesheet.css" rel="stylesheet">

Here the style I want (ONLY for the right side of the navbar):

.navbar-right{
   font-size:1em;
}

Can't do this...I'm able to change the style of navbar (everything, left and right side) but not ONLY for the right side...

I added a class .lang to navbar-right as suggested. Now I have this in CSS:

.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
  color:#383838 ;
  font-weight: bold;
  font-size:25px;
  letter-spacing: 0.7px;
  border-color: transparent;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
  color:#383838 ;
  font-weight: bold;
  font-size:25px;
  letter-spacing: 0.7px;
 border-color: transparent;
 }   

.lang {
  font-size: 1em;
 }

.lang >  .active > a,
.lang > .active > a:hover,
.lang > .active > a:focus {

  font-size:1.5em;
  letter-spacing: 0.7px;

 }

.lang>  li > a:hover,
.lang>  li >  a:focus {

  font-size:1.5em;
 letter-spacing: 0.7px;
}

It now changes the font of the right menu but, doesn't read the changes of the active class... it still reads the .navbar-default .navbar setting for active and hover links... I placed my .lang style AFTER the standard one so...I thought it was ok...

Upvotes: 0

Views: 1675

Answers (4)

gabbianella
gabbianella

Reputation: 1

So for me the solution was:

1) Add a .lang class to my .navbar-right (styling font and hover,focus cases)

2) Add a .no-lang class to the main .navbar .navbar-default to avoid overriding.

It worked for me...

Upvotes: 0

elreeda
elreeda

Reputation: 4597

add new class for example lang to ul and give the a insdie the ul a font-size

<ul class="lang nav navbar-nav navbar-right">
    <li class="active"><a href="#">IT</a></li>
    <li ><a href="#">EN</a></li>
    <li><a href="#">中文</a></li>
</ul>

and css:

ul.lang a{
  font-size: 3em;
}

working in this PEN

Upvotes: 1

farhan
farhan

Reputation: 101

Change the Font Size for you to attain the correct Formatting, by using the custom style overiding in css as follows

.navbar-right li a {font-size:1em;}

Upvotes: 0

Hybrid
Hybrid

Reputation: 7049

Try the following:

.navbar-right li a {
   font-size: 1em !important;
}

Upvotes: 0

Related Questions