因此,当在移动设备上查看我的网页时,在下拉导航中选择链接时,响应式导航菜单会自动关闭。在 android 和 iPhone 6s 上运行良好。刚刚在 iPhone 8 plus 上测试过,但由于某种原因自动关闭功能不起作用,必须手动关闭。关于如何解决它的任何想法?
//Javascript
//Auto-close responsive navbar after selection
$('.navbar-collapse ul li a').click(function(){
$('.navbar-toggle:visible').click();
});
//HTML - using Bootstrap 3
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="col-md-12">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img src="img/logo_flat.png" class="img-responsive" style="width: 140px; margin-top: -16px;"></a>
</div>
<div class="collapse navbar-collapse navbar-right" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active"><a href="#banner">Home</a></li>
<li class=""><a href="#aboutus">About Us</a></li>
<li class=""><a href="#whatwedo">What We Do</a></li>
<li class=""><a href="#faqs">FAQs</a></li>
<li class=""><a href="#careers">Careers</a></li>
<li class=""><a href="#contactus">Contact Us</a></li>
</ul>
</div>
</div>
</div>
</nav>