Bootstrap全宽导航栏侧面有两种不同的背景颜色

时间:2016-12-07 19:58:50

标签: html css navbar

我在容器中心的示例中使用标准全宽流体自举导航栏。我想要实现的是,我希望在徽标下方的左侧有白色背景,从徽标到右侧有蓝色背景颜色。可能吗? hope this image will explain谢谢。

3 个答案:

答案 0 :(得分:1)

这样做的一种方法很棘手但是有效

<强> HTML:

<div class="navbar navbar-default">
  <div class="container">
  <div class="navbar-header">
    <a class="navbar-brand" href="#">Brand</a>
  </div>
   <ul class="nav navbar-nav">
      <li><a href="#">Home</a></li>
      <li><a href="#">Link</a></li>
      <li><a href="#">Link</a></li>
      <li class="divider-vertical"></li>
      <li><a href="#">More</a></li>
  <li><a href="#">Options</a></li>
  </ul>
  </div>
</div>

<强> CSS:

.navbar-header{
    background:#e7e7e7;;
  position:relative;
}

.navbar-header:before {
    position: absolute;
    height: 100%;
    display: inline-block;
    background: #e7e7e7;;
    top: 0;
    left: -9999px;
    right: 100%;
}
.navbar-default{
    background:blue;
}

See demo1

如果你想扭曲边缘

See demo2

答案 1 :(得分:0)

也许你可以使用只有两种颜色的“锐利”渐变作为背景颜色 (使用http://www.colorzilla.com/gradient-editor/) 我在这里复制了bootstrap文档中的标准navbar示例:

.navbar{
background: rgb(255,255,255); /* Old browsers */
background: -moz-linear-gradient(left,  rgb(255,255,255) 0%, rgb(255,255,255) 20%, rgb(125,185,232) 20%); /* FF3.6-15 */
background: -webkit-linear-gradient(left,  rgb(255,255,255) 0%,rgb(255,255,255) 20%,rgb(125,185,232) 20%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to right,  rgb(255,255,255) 0%,rgb(255,255,255) 20%,rgb(125,185,232) 20%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#7db9e8',GradientType=1 ); /* IE6-9 */

}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<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" 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" 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-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">Separated link</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">One more separated link</a></li>
          </ul>
        </li>
      </ul>
      <form class="navbar-form navbar-left">
        <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-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">Separated link</a></li>
          </ul>
        </li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

答案 2 :(得分:0)

您可以尝试这样的线性渐变:

~/.ssh/id_{rsa,dsa,ecdsa,ed25519}

使用其他代码,我们可以为您提供更多帮助。