html – Bootstrap导航栏汉堡包图标不垂直对齐

前端之家收集整理的这篇文章主要介绍了html – Bootstrap导航栏汉堡包图标不垂直对齐前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用带有bootstrap 4.1.2的流畅套件.

navbar docs(我想要这个,因为切换器在打开/关闭时更改其图标)我确实从#position部分采取了第二个例子.但是,汉堡不是垂直居中的.我该如何解决

导航栏错误的汉堡包:

我尝试删除填充但它没有帮助,我被卡住了.

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/nespero/fluent-kit@1.3.0/js/fluent-kit.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdn.jsdelivr.net/gh/nespero/fluent-kit@1.2.0/css/fluent-kit.min.css" rel="stylesheet"/>

<nav class="navbar navbar-dark bg-dark py-2">
  <strong class="navbar-text">
    Navbar position example
  </strong>
  <button class="btn mi navbar-toggler  shadow-none mt-0" type="button" data-toggle="collapse" data-target="#navbar-position" aria-controls="navbar-position" aria-expanded="false" aria-label="Toggle navigation">
    <span class="sr-only">Toggle navbar submenu</span>
  </button>
  <div class="collapse navbar-collapse" id="navbar-position">
    <ul class="navbar-nav">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Features</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Pricing</a>
      </li>
      <li class="nav-item">
        <a class="nav-link disabled" href="#">Disabled</a>
      </li>
    </ul>
  </div>
</nav>

解决方法

从< button>中删除.btn类
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/nespero/fluent-kit@1.3.0/js/fluent-kit.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdn.jsdelivr.net/gh/nespero/fluent-kit@1.2.0/css/fluent-kit.min.css" rel="stylesheet"/>

<nav class="navbar navbar-dark bg-dark py-2">
  <strong class="navbar-text">
    Navbar position example
  </strong>
  <button class="mi navbar-toggler  shadow-none mt-0" type="button" data-toggle="collapse" data-target="#navbar-position" aria-controls="navbar-position" aria-expanded="false" aria-label="Toggle navigation">
    <span class="sr-only">Toggle navbar submenu</span>
  </button>
  <div class="collapse navbar-collapse" id="navbar-position">
    <ul class="navbar-nav">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Features</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Pricing</a>
      </li>
      <li class="nav-item">
        <a class="nav-link disabled" href="#">Disabled</a>
      </li>
    </ul>
  </div>
</nav>
原文链接:https://www.f2er.com/html/226325.html

猜你在找的HTML相关文章