gpt4 book ai didi

javascript - eBay 和 Bootstrap : collapse menu in javascript

转载 作者:行者123 更新时间:2023-12-03 07:24:48 24 4
gpt4 key购买 nike

有人可能知道 - 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>

最佳答案

要在没有 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>

关于javascript - eBay 和 Bootstrap : collapse menu in javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36045025/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com