修复后如何在滚动时将bootstrap navba-nav居中?

时间:2015-05-28 15:22:03

标签: javascript jquery html css twitter-bootstrap

我有一个数据属性data-spy =" affix"数据偏移顶=" 60" data-offset-bottom =" 200",所以滚动时它的位置是固定的。但它将它移到左边。我怎样才能保持中心。以下是操作中的代码http://leoroofingconstruction.com

<nav class="navbar navbar-default baraNav" >
  <div class="container-fluid">
    <h1 class="logo">Las Fiestas</h1>
    <!-- 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>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1" data-spy="affix" data-offset-top="60" data-offset-bottom="200">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home <span class="sr-only">(current)</span></a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Our Specialties <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>
        <li><a href="#">Our Menu</a></li>
        <li><a href="#">Events</a></li>
        <li><a href="#">Contact</a></li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

CSS:

&#13;
&#13;
@import url(http://fonts.googleapis.com/css?family=Tangerine);
@import url(http://fonts.googleapis.com/css?family=Exo+2:300);


.carousel-control.left, .right{
   display: none;
  }
.sliderIntro{
  font-family: 'Tangerine', cursive;
  font-size: 70px;
}

.pIntro{
  font-size: 15px;
  font-family: 'Exo 2', sans-serif;
}
    .Me{
      font-size: 15px;
      font-family: 'Exo 2', sans-serif;
      color: #2ebc58;
    }
    .xi{
      font-size: 15px;
      font-family: 'Exo 2', sans-serif;
      color: #ffffff;
    }
    .can{
      font-size: 15px;
      font-family: 'Exo 2', sans-serif;
      color: #ff0000;
    }


.logo{
  font-family: 'Tangerine', cursive;
  font-size: 100px;
  text-align: center;
  color:#ffffff;
}

.baraNav{
  margin-top: -730px;
}

.navbar .navbar-nav {
    display: inline-block;
    float: none;
}

.navbar .navbar-collapse {
 text-align: center;
}
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

必要时添加.affix - width 100%