bootstrap导航条的二级菜单下实现三级菜单

bootstrap在导航条中的二级菜单下实现三级菜单

modify by 20180506 add music

border="0" width="330" height="86" src="//music.163.com/outchain/player?type=2&id=446177349&auto=1&height=66">

update 20180919:
推广下自己的公众号,打算以后系列文章会维护在微信公众号上,有兴趣的朋友可以关注哟,多数系列文章可能会围绕python系列进行展开:

在这里插入图片描述

直接上代码

<!--html里的写法,直接搭好bootstrap导航条结构
	这里就用美食来做例子吧-->



		<!--反色的导航条-->
		<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
			<div class="container-fluid">
				<!-- Brand and toggle get grouped for better mobile display -->
				<div class="navbar-header">
					<button type="button" class="navbar-toggle collapsed" 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="#">
									美食之家  <span class="glyphicon glyphicon-cutlery"></span>
								</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="#">首页</a></li>
						<li class="dropdown">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown">菜谱 
							<span class="caret"></span></a>
							<ul class="dropdown-menu" role="menu">
								<li class="dropdown-submenu">  
									<a href="#">主食</a>
									<ul class="dropdown-menu">  
										<li><a href="#">饭</a></li>  
                        				<li><a href="#">饼</a></li>  
                        				<li><a href="#">包子</a></li>
                    				</ul>  
								</li>
								<li><a href="#">肉类</a></li>
								<li><a href="#">水产</a></li>
							</ul>
						</li>
						<li><a href="#">食材</a></li>
						<li><a href="#">健康</a></li>
						<li><a href="#">话题</a></li>
						<li><a href="#">活动</a></li>
					</ul>
</nav>

<!--CSS样式-->

		<style>
			body {
				padding-top: 70px;
			}
			
			
			
			/*自定义的css*/
			.dropdown-submenu {
				position: relative;
			}
			
			.dropdown-submenu>.dropdown-menu {
				top: 0;
				left: 100%;
				margin-top: -6px;
				margin-left: -1px;
				-webkit-border-radius: 0 6px 6px 6px;
				-moz-border-radius: 0 6px 6px;
				border-radius: 0 6px 6px 6px;
			}
			
			.dropdown-submenu:hover>.dropdown-menu {
				display: block;
			}
			
			.dropdown-submenu>a:after {
				display: block;
				content: " ";
				float: right;
				width: 0;
				height: 0;
				border-color: transparent;
				border-style: solid;
				border-width: 5px 0 5px 5px;
				border-left-color: #ccc;
				margin-top: 5px;
				margin-right: -10px;
			}
			
			.dropdown-submenu:hover>a:after {
				border-left-color: #fff;
			}
			
			.dropdown-submenu.pull-left {
				float: none;
			}
			
			.dropdown-submenu.pull-left>.dropdown-menu {
				left: -100%;
				margin-left: 10px;
				-webkit-border-radius: 6px 0 6px 6px;
				-moz-border-radius: 6px 0 6px 6px;
				border-radius: 6px 0 6px 6px;
			}
		</style>

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 创作都市 设计师:CSDN官方博客 返回首页