Bootstrap 4 navbar-toggler-icon未出现

lkaoscv7  于 2023-11-15  发布在  Bootstrap
关注(0)|答案(5)|浏览(151)

访问:https://jsfiddle.net/8tpm4z00/

<div class="container">

  <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#myNavigation" aria-controls="myNavigation" aria-expanded="false" aria-label="Toggle navigation">
  <span class="navbar-toggler-icon"></span>
  </button>

  <a href="#" class="navbar-brand">KP</a>

  <div class="collapse navbar-collapse" id="myNavigation">
      <div class="navbar-nav">
        <a class="p-3 nav-item nav-link active " href="#">Home</a>
        <a class="p-3 nav-item nav-link " href="#">About</a>
        <a class="p-3 nav-item nav-link " href="#">Contact Me</a>
      </div><!-- <div class="navbar-nav"> -->
  </div><!-- <div class="collapse navbar-collapse"> -->

</div><!-- <div class="container"> -->

字符串
当菜单为移动的响应而折叠时,.navbar-toggler-icon不会出现在导航栏切换器按钮上。
我已经搜索了这个问题,并调整了jquery和bootstrap链接。通过将jquery链接放在bootstrap 4链接之上。但这似乎不起作用。外部库在我的HTML中以与jsfiddle相同的顺序链接。

r6vfmomb

r6vfmomb1#

最新消息:

navbar-inverse在B4版本中不再可用,您可以使用navbar-dark
使用navbar-inverse bg-inverse代替.navbar-default

<section role="navigation">
  <nav class="navbar navbar-inverse bg-inverse navbar-toggleable-sm fixed-top"><!-- navbar-inverse -->

    <div class="container">

      <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#myNavigation" aria-controls="myNavigation" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
      </button>

      <a href="#" class="navbar-brand">KP</a>

      <div class="collapse navbar-collapse" id="myNavigation">
          <div class="navbar-nav">
            <a class="p-3 nav-item nav-link active " href="#">Home</a>
            <a class="p-3 nav-item nav-link " href="#">About</a>
            <a class="p-3 nav-item nav-link " href="#">Contact Me</a>
          </div><!-- <div class="navbar-nav"> -->
      </div><!-- <div class="collapse navbar-collapse"> -->

    </div><!-- <div class="container"> -->

  </nav>
</section>

字符串
Updated fiddle

nhhxz33t

nhhxz33t2#

如果使用bootstrap 4 beta:

您只能在 nav 标签中添加navbar-dark类。
测试结果:

<nav class = "navbar navbar-expand-lg navbar-dark fixed-top navbar-default" role = "navigation">
     <a class="navbar-brand" href="#">
         <img class = "img-responsive logo" src = "~/Content/Images/ogo__160x36.png" alt = "" />
     </a>
     <button type = "button" class = "navbar-toggler" data-toggle = "collapse" data-target = "#menuPrincipal" aria-controls = "navbarNav" aria-expanded = "false" aria-label = "Toggle navigation ">
         <span class = "navbar-toggler-icon"> </ span>
     </button>
     <div class="collapse navbar-collapse" ...>...</div>
</nav>

字符串

tvmytwxo

tvmytwxo3#

如果您不使用navbar-light或dark设置background-img一些图像到.navbar-toggler-icon,如下所示

.navbar-toggler-icon {
background-image: url(data:image/svg+xml,%3csvg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000…p='round' stroke-miterlimit='10' d='M47h22M4 15h22M423h22'/%3e%3c/svg%3e);
}

字符串
或者使用字体awsome中的fa-bars

eoigrqb6

eoigrqb64#

使用navbar-dark代替navbar-inverse,使用bg-dark代替bg-inverse

<nav class="navbar navbar-dark navbar-expand-md bg-dark ">

字符串

vvppvyoh

vvppvyoh5#

我已将class="navbar-toggler"替换为class="btn"
代码如下所示:

<!--Toggler-->
<button class="btn" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasNavbar" aria-controls="offcanvasNavbar" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
</button>

字符串
有时灵

相关问题