我正在尝试创建一个多级下拉菜单,但没有达到很远,我想在下拉菜单中有:
1.one menu option
- sub-menu option
- sub-menu option
- sub-menu option
2.another menu
- sub-menu option
等
主菜单中最多有4个选项,每个菜单项都有子菜单。
这是我到目前为止所拥有的:
<div class="container">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">Categories
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="#">Sports</a></li>
<li class="dropdown-submenu">
<a class="test" tabindex="-1" href="#">... <span class="caret"></span></a>
<li><a tabindex="-1" href="#">Pop Culture</a></li>
<li class="dropdown-submenu">
<a class="test" tabindex="-1" href="#">... <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="#">2nd level dropdown</a>
</li>
<li><a tabindex="-1" href="#">2nd level dropdown</a>
</li>
<li><a tabindex="-1" href="#">Tazos</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
任何帮助都非常感谢....
答案 0 :(得分:0)
这会对你有所帮助:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.dropdown-submenu {
position: relative;
}
.dropdown-submenu .dropdown-menu {
top: 0;
left: 100%;
margin-top: -1px;
}
</style>
</head>
<body>
<div class="container">
<h2>Multi-Level Dropdowns</h2>
<p>In this example, we have created a .dropdown-submenu class for multi-level dropdowns (see style section above).</p>
<p>Note that we have added jQuery to open the multi-level dropdown on click (see script section below).</p>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">Tutorials
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="#">HTML</a></li>
<li><a tabindex="-1" href="#">CSS</a></li>
<li class="dropdown-submenu">
<a class="test" tabindex="-1" href="#">New dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="#">2nd level dropdown</a></li>
<li><a tabindex="-1" href="#">2nd level dropdown</a></li>
<li class="dropdown-submenu">
<a class="test" href="#">Another dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">3rd level dropdown</a></li>
<li><a href="#">3rd level dropdown</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<script>
$(document).ready(function(){
$('.dropdown-submenu a.test').on("click", function(e){
$(this).next('ul').toggle();
e.stopPropagation();
e.preventDefault();
});
});
</script>
</body>
</html>
另一个链接:https://codepen.io/ajaypatelaj/pen/prHjD
根据您的要求编辑代码
答案 1 :(得分:0)
http://www.monolinea.com/responsive-multilevel-menu-with-bootstrap-3/
我打算试试这个傻逼。如果这不起作用,那么我不知道,也许我只需要制作多个菜单。Smartmenus似乎是我需要的。
看起来它会让我这样做:
1.menu
Options
2.menu
Options
3.menu
Options
4.menu
Options
所有这一切都与bootstrap很好地配合,反过来,我的网络应用程序: - )