如何修复而无需移动标志牌,以中心为中心的菜单?

问题描述 投票:1回答:1

我想我的中心导航栏菜单,但我不希望我的标志导航栏品牌太多移动,但我也试图与文本的中心,但它似乎没有什么工作。我更新的代码,并去除容器类,但在第二列表中的第三列表

.nav.navbar-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}
@media (min-width: 768px) {
    .navbar-nav {
        float: none;
    }
}

HTML

<div class="wrapper">
  <!-- Header-->
  <nav class="navbar navbar-default" 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>
    </div>
    <div class="nav-bar-container">
      <ul class="nav navbar-nav navbar-left">
        <li><a href="#">Left</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-center">
        <li><a href="#">Center 1</a></li>
        <li><a href="#">Center 2</a></li>
        <li><a href="#">Center 3</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Right</a></li>
      </ul>
    </div>
  </nav>
</div>

加入后,我的问题

.nav.navbar-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}


.nav-bar-container{
  display: flex;
  justify-content: space-between;
}

@media (max-width: 768px) {
    .nav-bar-container{
        display: none;
    }
}

center

twitter-bootstrap css3
1个回答
0
投票

我建议去掉容器类,并添加你自己的,因为它有一些!important规则。使用

display: flex;
justify-content: space-between;

.nav.navbar-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}


.nav-bar-container{
  display: flex;
  justify-content: space-between;
}

@media (max-width: 768px) {
    .nav-bar-container{
        display: none;
    }
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<div class="wrapper">
  <!-- Header-->
  <nav class="navbar navbar-default" 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>
    </div>
    <div class="nav-bar-container">
      <ul class="nav navbar-nav navbar-left">
        <li><a href="#">Left</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-center">
        <li><a href="#">Center 1</a></li>
        <li><a href="#">Center 2</a></li>
        <li><a href="#">Center 3</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Right</a></li>
      </ul>
    </div>
  </nav>
</div>
© www.soinside.com 2019 - 2024. All rights reserved.