Bootstrap 4切换菜单“下拉”(仅在移动视图中)

时间:2018-09-11 01:33:02

标签: html5 css3 bootstrap-4

我在网站的顶部有一个简单的导航栏,仅包含两个链接。当视图变为移动设备(平板电脑和/或移动设备)时,这些链接消失,并显示菜单“汉堡”图标。但是,当我单击它时,什么也没有显示。我希望在单击菜单图标时都显示两个链接。

Desktop view Mobile view

/* Registration Navbar */

.registration-navbar {
  background-color: #8ABE57;
  height: 45px;
}

.registration-navbar ul li a {
  color: #ffffff;
  font-size: 0.8em;
}

.registration-navbar ul li a:hover {
  color: #31353D;
}

.navbar-dark,
.navbar-toggler {
  border: none;
  color: rgba(255, 255, 255, 0);
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">

<nav class="navbar navbar-expand-lg navbar-dark registration-navbar">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                  <span class="navbar-toggler-icon"></span>
                </button>
  <div class="collapse navbar-collapse my-auto" id="navbarNav">
    <ul class="navbar-nav ml-auto">
      <li class="nav-item active">
        <a class="nav-link" href="#">Mi Cuenta</a>
      </li>
      <li class="nav-item active">
        <a class="nav-link" href="#">Registrarme</a>
      </li>
    </ul>
  </div>
</nav>

1 个答案:

答案 0 :(得分:1)

从.registration-navbar删除高度:45px,这将解决问题。

/* Registration Navbar */

.registration-navbar {
  background-color: #8ABE57;
}

.registration-navbar ul li a {
  color: #ffffff;
  font-size: 0.8em;
}

.registration-navbar ul li a:hover {
  color: #31353D;
}

.navbar-dark,
.navbar-toggler {
  border: none;
  color: rgba(255, 255, 255, 0);
}