我无法弄清楚为什么在手机/平板电脑上没有显示引导菜单? 你可以在这里看到:https://simpleeats.cratejoy.com/
答案 0 :(得分:1)
由于您的navbar-brand
设置为100%宽度,它实际上覆盖了您的navbar-toggle
按钮,这就是为什么当您点击切换按钮时,您将被定向回索引页面:请参阅图像。< / p>
您可以更改navbar-toggle
班级(z-index: 1060;
的作品)的z-index,也可以设置图片的宽度。
旁注:当您打开菜单时,您会看到因徽标附加img-responsive
类而导致的一些不利行为,但您不应该需要此课程。
固定宽度,居中navbar-brand
图像的工作演示。
/**FOR DEMO ONLY**/
.navbar .navbar-brand {
padding-top: 0;
}
.navbar .navbar-toggle.lefty {
float: left;
margin-left: 15px;
}
/**FOR DEMO ONLY**/
@media (max-width: 768px) {
.navbar .navbar-brand {
position: absolute;
width: 200px;
left: 50%;
transform: translateX(-50%);
background: red;
}
.navbar .navbar-brand img {
margin: 0 auto;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-default">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-nav" 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="#">
<img src="http://placehold.it/150x50">
</a>
<!--FOR DEMO ONLY -->
<button type="button" class="navbar-toggle collapsed lefty" data-toggle="collapse" data-target="#bs-nav" 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>
<!--FOR DEMO ONLY -->
</div>
<div class="collapse navbar-collapse" id="bs-nav">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#">Link <span class="sr-only">(current)</span></a>
</li>
<li><a href="#">Link</a>
</li>
</ul>
</div>
</nav>
答案 1 :(得分:0)
尝试添加aria-controls =&#34; bs-example-navbar-collapse-1&#34;
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false" aria-controls="bs-example-navbar-collapse-1">