Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Language picker in the navbar right side with Bootstrap

I have this part of code:

<div id="navbar-main">
  <!-- Fixed navbar -->
  <div class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="icon icon-heart" style="font-size:30px; color:#3498db;"></span>
          </button>
        <a class="navbar-brand hidden-xs hidden-sm" href="#home"><span class="icon icon-heart" style="font-size:18px; color:#3498db;"></span></a>
      </div>
      <div class="navbar-collapse collapse">
        <ul class="nav navbar-nav">
          <li><a href="#home" class="smoothScroll">Home</a></li>
          <li> <a href="#about" class="smoothScroll"> About</a></li>
          <li> <a href="#houses" class="smoothScroll"> Houses</a></li>
          <li> <a href="#products" class="smoothScroll"> Products</a></li>
          <li> <a href="#contact" class="smoothScroll"> Contact</a></li>
          <li>
            <a href="#" class="language" rel="it-IT"><img src="assets/img/it_IT.png" alt="Italiano" /></a>
          </li>
          <li>
            <a href="#" class="language" rel="en-US"><img src="assets/img/en_US.png" alt="English" /></a>
          </li>
      </div>
      <!--/.nav-collapse -->

    </div>
  </div>
</div>

I would put this language picker

<li>
  <a href="#" class="language" rel="it-IT"><img src="assets/img/it_IT.png" alt="Italiano" /></a>
</li>
<li>
  <a href="#" class="language" rel="en-US"><img src="assets/img/en_US.png" alt="English" /></a>
</li>

in the right side of the navbar and if it's possible in a dropdown menu.

How can I do this? I tried with pull-right and dropdown-menu class attributes, but without success.

like image 987
sharkbait Avatar asked Dec 15 '22 15:12

sharkbait


1 Answers

From the bootstrap documentation I found this:

<ul class="nav navbar-nav navbar-right">
    <li><a href="#">Link</a></li>
    <li class="dropdown">
      <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a>
      <ul class="dropdown-menu" role="menu">
        <li><a href="#">Action</a></li>
        <li><a href="#">Another action</a></li>
        <li><a href="#">Something else here</a></li>
        <li class="divider"></li>
        <li><a href="#">Separated link</a></li>
      </ul>
    </li>
  </ul>

then in your snipped...

<div id="navbar-main">
    <!-- Fixed navbar -->
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"><span class="icon icon-heart" style="font-size:30px; color:#3498db;"></span></button>
            <a class="navbar-brand hidden-xs hidden-sm" href="#home"><span class="icon icon-heart" style="font-size:18px; color:#3498db;"></span></a>
        </div>
        <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
                <li><a href="#home" class="smoothScroll">Home</a></li>
                <li> <a href="#about" class="smoothScroll"> About</a></li>
                <li> <a href="#houses" class="smoothScroll"> Houses</a></li>
                <li> <a href="#products" class="smoothScroll"> Products</a></li>
                <li> <a href="#contact" class="smoothScroll"> Contact</a></li>
                <li><a href="#" class="language" rel="it-IT"><img src="assets/img/it_IT.png" alt="Italiano" /></a></li>
                <li><a href="#" class="language" rel="en-US"><img src="assets/img/en_US.png" alt="English" /></a></li>
            </ul>
        </div><!--/.nav-collapse -->

        <ul class="nav navbar-nav navbar-right">
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu">
                    <li><a href="#">Action</a></li>
                    <li><a href="#">Another action</a></li>
                    <li><a href="#">Something else here</a></li>
                    <li class="divider"></li>
                    <li><a href="#">Separated link</a></li>
                </ul>
            </li>
        </ul>
    </div>
</div>

like image 92
RikyTres Avatar answered Jan 12 '23 04:01

RikyTres