Nav-bar multicolored Bootstrap

Asked

Viewed 1,232 times

1

I have to leave my multicolored Nav-bar?

For example, half one color, half another?

I want to do something in that style but I don’t want those degrade marks.

2 answers

0

Doing inside the navbar, two areas and each of them assign a color that makes canceling the main color ( the default navbar ).

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;
}
  • I want to do something like this jsfiddle.net/3brhrrgf/4/Embedded/result without the gradient marks. You can show me how it would be done?

  • gradient marks? What do you mean?

  • Leave it, I already managed using another solution, thank you.

0


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

Example in 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 bootstrap with the example menu code contained in the documentation (Simply override the standard 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>
<link href="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>
<nav class="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: http://jsfiddle.net/3brhrrgf/1/

FOLLOWING YOUR NEW REQUEST: http://jsfiddle.net/3brhrrgf/9/

More about linear-gradient: Linear Gradient

  • I want to do something like this https://jsfiddle.net/3brhrrgf/4/embedded/result/ But I don’t want these degrade marks. You know how to resolve this?

  • Not because this is the normal behavior of the property, after all it is a degrade.

  • But in your example you do not have these marks. You do not have any property that changes the gradient range?

  • So good: http://jsfiddle.net/3brhrrgf/9/ ?

  • Unfortunately not, when you switch to a browser resolution it distorts. There is some other solution that does not involve gradient?

  • It adapts as it should be. And no, I don’t. Follow the other answer below, maybe it works.

  • Even with the gradient problem, it was the answer that helped me the most.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.