我有这样的导航:
<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也
答案 0 :(得分:1)
有一个简单而且非常好的解决方案HERE,THIS详细解释了不同的菜单选项。 如果您想了解它在移动环境中的反应,只需重新调整浏览器窗口的大小。
标记看起来像这样:
<!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>