gpt4 book ai didi

jquery - 手机自定义菜单

转载 作者:太空宇宙 更新时间:2023-11-04 12:17:23 26 4
gpt4 key购买 nike

我有这样的导航:

<nav id="menu">
<ul>
<li><a href="/preview/">Home</a>
</li>
<li class="dropdown"> <a href="/preview/#about-us" class="dropdown-toggle scroll" data-toggle="dropdown" data-hover="dropdown">About Us <i class="fa fa-angle-down"></i></a>

<ul class="menulist dropdown-menu">
<li><a href="history.php">History</a></li>
<li><a href="our-pledge.php">Our Pledge</a></li>
<li><a href="giving-back.php">Giving Back</a></li>
<li><a href="awards.php">Awards</a></li>
<li><a href="in-the-press.php">In The Press</a></li>
<li><a href="design-centre.php?action=video-testimonials">Video Tertimonials</a></li>
</ul>
</li>
<li><a href="/preview/#communities">Communities</a></li>
<li><a href="/preview/#pronto">Pronto</a></li>
<li><a href="/preview/#gallery">Gallery</a></li>
<li><a href="/preview/#virtual-tours">Virtual Tours</a></li>
<li class="dropdown"> <a href="/preview/#design-centre" class="dropdown-toggle scroll" data-toggle="dropdown" data-hover="dropdown">Design Centre <i class="fa fa-angle-down"></i></a>

<ul class="menulist dropdown-menu">
<li><a href="design-centre.php?action=video-testimonials">Video Tertimonials</a></li>
<li><a href="design-centre.php?action=meet-the-team">Meet The Team</a></li>
<li><a href="design-centre.php?action=faq">FAQ</a></li>
</ul>
</li>
<li class="dropdown"> <a href="/preview/#customer-care" class="dropdown-toggle scroll" data-toggle="dropdown" data-hover="dropdown">Customer Care <i class="fa fa-angle-down"></i></a>

<ul class="menulist dropdown-menu">
<li><a href="warranty-information.php">Warranty Information</a></li>
<li><a href="home-maintenance.php">Home Maintenance Tips</a></li>
<li><a href="emergencies.php">Emergencies</a></li>
</ul>
</li>
</ul>
</nav><!--menu-->

对于移动设备,我添加了这个元素:

<button class="navbar-toggle button-white menu" data-toggle="collapse" data-target=".navbar-collapse"> 
<i class="fa fa-bars"></i>
</button>

目前,如果是移动设备,菜单不会出现,但按钮会出现。当它是移动时,我正在寻找用户单击按钮,然后出现带有菜单选项的下拉菜单。我的问题是这样做的最佳方法是什么?

我安装了 bootstrap.js 和 bootstrap-hover-dropdown.min.js

最佳答案

有一个简单且非常好的解决方案可以做到这一点 HERE , 与 THIS不同菜单选项的详细解释。如果您想查看它在移动环境中的 react ,只需重新调整浏览器窗口的大小即可。

标记如下所示:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example of Bootstrap 3 Dropdowns within a Navbar</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<style type="text/css">
.bs-example{
margin: 20px;
}
</style>
</head>
<body>
<div class="bs-example">
<nav id="myNavbar" class="navbar navbar-default" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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="#">Brand</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="#">Home</a></li>
<li><a href="#">Profile</a></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-toggle">Messages <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Inbox</a></li>
<li><a href="#">Drafts</a></li>
<li><a href="#">Sent Items</a></li>
<li class="divider"></li>
<li><a href="#">Trash</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-toggle">Admin <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li class="divider"></li>
<li><a href="#">Settings</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div>
</nav>
</div>
</body>
</html>

关于jquery - 手机自定义菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28593400/

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