[英]How to show a menu icon on mobile devices in Bootstrap nav?
When I view my site on mobile, the navbar works except there is not a mobile menu icon. 当我在移动设备上查看网站时,导航栏将起作用,但没有移动菜单图标。 That is to say, if you tap the far right of the nav bar, the <li>
elements get toggled, but there is no icon in the spot where you tap to toggle the <li>
elements, so users will not know to do it. 也就是说,如果您点击导航栏的最右侧,则会切换<li>
元素,但是在您点击以切换<li>
元素的位置没有图标,因此用户将不知道该怎么做。它。
Thanks in advance for any pointers, it is much appreciated. 在此先感谢您的任何指点,不胜感激。
HTML: HTML:
<nav class="navbar navbar-light" style="background-color:#e3f2fd;">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">
Home
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="/topics">All Topics</a></li>
<li class="dropdown">
<a href="/topics" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Featured Topics <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="/topics/US Presidents/new">U.S. Presidents</a></li>
<li><a href="/topics/Astronomy/new">Astronomy</a></li>
<li><a href="/topics/Movies/new">Movies</a></li>
</ul>
</li>
<li><a href="/newest-quizzes">Newest Quizzes<span class="sr-only">(current)</span></a></li>
<li><a href="/create-quiz">Create</a></li>
<li><a href="/about">About</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="/login">Login</a></li>
<li><a href="/register">Create Account</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
Could you try exchanging the class navbar-light
by navbar-default
or navbar-inverse
on your nav
element? 您可以尝试在nav
元素上通过navbar-default
或navbar-inverse
交换类navbar-light
吗? navbar-light
doesn't exist in Bootstrap 3. 引导程序3中不存在navbar-light
。
Make sure your Bootstrap dependencies are included in the correct order. 确保以正确的顺序包含Bootstrap依赖项。 Any discrepancy will tend to break things. 任何差异都会使事情破裂。
you can style button.navbar-toggle
to see that button 您可以设置button.navbar-toggle
样式以查看该按钮
for example, 例如,
button.navbar-toggle {
background:#ddd !important; /* !important is just to override other styles, if any. */
}
hope that helps! 希望有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.