正如有人知道 - eBay不尊重,例如。 jQuery的。我想用响应式菜单制作响应式模板,但我不知道我应该怎么做菜单。我必须从bootstrap删除所有jQuery,现在菜单切换不起作用,例如。智能手机。我该怎么办?
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-headerOne">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="#">Project name</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#">Store</a></li>
<li><a href="#payments">Payments</a></li>
<li><a href="#shipping">Shipping</a></li>
<li><a href="#returns">Returns</a></li>
<li><a href="#terms">Terms</a></li>
<li><a href="#gurantee">Gurantee</a></li>
<li><a href="#about">Abous us</a></li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</nav>
答案 0 :(得分:1)
要在没有javascript的情况下创建这些菜单,您必须使用一些CSS。也许这个链接可以帮助您解决类似的问题:bootstrap-without-jquery
以下是针对您的特定问题的解决方案:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<style>
/* Dropdown without JS */
.dropdown-toggle:focus {
pointer-events: none;
}
.dropdown-toggle:focus + .dropdown-menu {
opacity: 1;
visibility: visible;
pointer-events: auto;
}
.dropdown-menu {
opacity: 0;
display: block;
visibility: hidden;
transition: visibility 0.5s;
}
</style>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="dropdown-toggle navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<ul class="dropdown-menu" style="position:absolute;right:0;">
<li class="">
<a href="/menu1/">menu1 <span class="sr-only">(current)</span></a>
</li>
<li class="">
<a href="/menu2/">menu2 <span class="sr-only">(current)</span></a>
</li>
<li class="dropdown active">
<a href="/menu3/">menu3 <span class="sr-only">(current)</span></a>
</li>
<li class=""><a href="/menu3/submenu1/">submenu1
<span class="sr-only">(current)</span></a>
</li>
<li class=""><a href="/menu3/submenu2/">submenu2
<span class="sr-only">(current)</span></a>
</li>
</ul>
<a class="navbar-brand" href="/"
style="background: white; padding-left: 50px;">App</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 class=""><a href="/menu1/">menu1
<span class="sr-only">(current)</span></a>
</li>
<li class=""><a href="/menu2/">menu2
<span class="sr-only">(current)</span></a>
</li>
<li class="dropdown active">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">menu3
<span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li class=""><a href="/menu3/typ/A/">A</a></li>
<li class=""><a href="/menu3/typ/B/">B</a></li>
<li class=""><a href="/menu3/typ/C/">C</a></li>
<li class=""><a href="/menu3/typ/D/">D</a></li>
</ul>
</li>
<li class=""><a href="/menu3/submenu1/">menu3
<span class="sr-only">(current)</span></a>
</li>
</ul>
<i class="navbar-text navbar-right">
<a href="/logout" style="">Logout</a>
</i>
</div>
</div>
<!-- /.container-fluid -->
</nav>