html – Bootstrap navbar-brand上面的菜单,直到调整大小并崩溃

我一直在寻找一个这样的例子,找不到任何东西.我使用常规文本作为我的导航栏品牌(没有图像),但字体是200-300%并占用了大量空间.我想将名称放在菜单上方.但是,当窗口调整大小时,我需要它折叠到导航栏的中心(当链接折叠时).

应该看起来像这样:

                             WEBSITE NAME
         link     link1    link2      link3   link4     link5

并陷入困境

                             WEBSITE NAME                ==

所以,现在这就是我正在使用的.两侧带链接的居中文本,但由于不切实际的尺寸,链接在导航栏品牌后面溢出.

<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="navbar-header">
    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>    
    <a class="navbar-brand" href="#">BIG WEBSITE TITLE</a>
  </div>
  <div class="collapse navbar-collapse">
    <ul class="nav navbar-nav navbar-left">
        <li id="nav">LINK for: </li>
        <li id="nav"><a href="#"><i class="fa fa-mars" aria-hidden="true"></i> LINK</a></li>
        <li id="nav"><a href="#"><i class="fa fa-venus" aria-hidden="true"></i> LINK</a></li>
        <li id="nav"><a href="#">LINK</a></li>
    </ul>
    <ul class="nav navbar-nav navbar-right">
      <li><a href="#">LINK</a></li>
      <li><a href="#">LINK</a></li>
    </ul>
  </div>
</nav>

一些CSS

.navbar-brand
{
    font-size: 200%;
    position: absolute;
    width: 100%;
    left: 0;
    text-align: center;
    margin:0 auto;
}
.navbar-toggle {
    z-index:3;
}

@media (min-width: 768px) {
.navbar-brand,
.navbar-nav li a {
    line-height: 70px;
    height: 70px;
    padding-top: 0px;
    padding-bottom: 0px;
    margin-bottom: 0px;
}
    .navbar-nav li {
    line-height: 70px;
    height: 70px;
    padding-top: 0px;
    padding-bottom: 0px;
    margin-bottom: 0px;
    margin-left: 10px;
}
    .navbar-brand
    {
    font-size: 300%;
    position: absolute;
    width: 100%;
    left: 0;
    text-align: center;
    vertical-align: middle;
    margin: auto;
}

.navbar{
    background-color: #ZZZZZ;
}

这对我来说根本不起作用.

最佳答案 这应该做到这一点

@media (min-width: 768px) {
  .navbar-nav.navbar-center, .navbar-header-center {
    margin-left: 50%;
    transform: translateX(-50%);
  }
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

    <nav class="navbar navbar-default" role="navigation">
      <div class="navbar-header navbar-header-center">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>    
        <a class="navbar-brand" href="#">Brand</a>
      </div>
      <div class="clearfix"></div>
      <div class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-center">
           <li><a href="#">Link1</a></li>
           <li><a href="#about">Link2</a></li>
          <li><a href="#about">Link3</a></li>
          <li><a href="#contact">Link4</a></li>
        </ul>
      </div>
    </nav>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
点赞