Bootstrap Nav-bar multicolored

1

How can I make my nav-bar multicolored?

For example, half of one color, half of another?

I want to do something in that style but I do not want those gradients.

    
asked by anonymous 14.02.2015 / 20:22

2 answers

0

I'm not sure how bootstrap works but my suggestion is that you work with linear gradient.

Example on a simple menu:

nav {
  text-align: center;
  background: linear-gradient(to right, #000 50%, #F00 50%); /* Para mais cores, adicione uma virgula, seguido do código HEX e a porcentagem de forma equivalente entre elas */
}

nav ul li {
  display: inline-block;
}

a {
  margin: 40px;
  color: #FFF;
  text-decoration: none;
  font: 14px bold "Trebuchet MS", sans-serif;
}
<nav>
   <ul>
     <li><a href="#">Lorem</a></li>
     <li><a href="#">Lorem</a></li>
     <li><a href="#">Lorem</a></li>
     <li><a href="#">Lorem</a></li>
   </ul>
</nav>

Example using the bootstrap with the example menu code contained in the documentation (Just overwrite the default rule):

.navbar-default {
    background: linear-gradient(to right, #000 50%, #F00 50%);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script><linkhref="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script><navclass="navbar navbar-default">
  <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">
        <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="#">Brand</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 class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
        <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>
            <li class="divider"></li>
            <li><a href="#">One more separated link</a></li>
          </ul>
        </li>
      </ul>
      <form class="navbar-form navbar-left" role="search">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search">
        </div>
        <button type="submit" class="btn btn-default">Submit</button>
      </form>
      <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>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

JSFIDDLE: link

FOLLOWING YOUR NEW ORDER : link

More on linear-gradient: Linear Gradient

    
14.02.2015 / 21:30
0

By doing within the navbar, two areas and each of them assign a color that cancels the main color (navbar default).

In html:

 <div class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
       <div class="area1">
           /*Conteudo da primeira metade da navbar*/
       </div>
       <div class="area2">
           /*Conteudo da segunda metade da navbar*/
       </div>
     </div>
  </div>

In css:

.area1{
background-color: red !important;
width: 50%;
float: left;
}

.area2{
background-color: blue !important;
width: 50%;
float: right;
}
    
14.02.2015 / 21:27