<nav class="navbar navbar-expand-md navbar-light bg-primary">
<a class="navbar-brand" href="#">Brand</a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbarSupportedContent">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">Home</li>
</ul>
</div>
</nav>
使用上面的代码,当我在桌面上查看页面时,我仍然可以看到切换按钮
最佳答案
您在切换按钮中使用了错误的类名。使用navbar-toggler
代替navbar-toggle
Reference Link bootstrap4 navbar
堆栈片段
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<nav class="navbar navbar-expand-md navbar-light bg-primary">
<a class="navbar-brand" href="#">Brand</a>
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbarSupportedContent">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">Home</li>
</ul>
</div>
</nav>
关于jquery - 在桌面 View 上看到切换按钮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48376200/