2-7作业导航问题
html为
<!DOCTYPE html>
<html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>慕课网</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/css.css" rel="stylesheet" type="text/css">
<link href="css/layout.css" rel="stylesheet" type="text/css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<header id="page-head">
<div class="head-box">
<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="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<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="#">imooc</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 navbar-left">
<li class="active"><a href="#">首页 <span class="sr-only">(current)</span></a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" >生日 <span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<ul>
<li><a href="#">关系</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">朋友</a></li>
<li><a href="#">爱人</a></li>
<li><a href="#">姐妹</a></li>
</ul>
</li>
<li>
<ul>
<li><a href="#">风味</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">巧克力</a></li>
<li><a href="#">水果</a></li>
</ul>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">婚礼 <span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<ul>
<li><a href="#">关系</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">朋友</a></li>
<li><a href="#">爱人</a></li>
<li><a href="#">姐妹</a></li>
</ul>
</li>
<li>
<ul>
<li><a href="#">风味</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">巧克力</a></li>
<li><a href="#">水果</a></li>
</ul>
</li>
<li>
<ul>
<li><a href="#">主旋律</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">心形</a></li>
<li><a href="#">卡通</a></li>
</ul>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">专用 <span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<ul>
<li><a href="#">关系</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">朋友</a></li>
<li><a href="#">爱人</a></li>
<li><a href="#">姐妹</a></li>
</ul>
</li>
<li>
<ul>
<li><a href="#">风味</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">巧克力</a></li>
<li><a href="#">水果</a></li>
</ul>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">商铺 <span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<ul>
<li><a href="#">关系</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">朋友</a></li>
<li><a href="#">爱人</a></li>
<li><a href="#">姐妹</a></li>
</ul>
</li>
<li>
<ul>
<li><a href="#">风味</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">巧克力</a></li>
<li><a href="#">水果</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href=""><span class="glyphicon glyphicon-search"></span>
</a>
<div class="glyphicon glyphicon-triangle-top icon-menu"></div>
<div class="search icon-menu">
<form>
<input type="text" name="search">
<button>搜</button>
</form>
</div>
</li>
<li><a href=""><span class="glyphicon glyphicon-user"></span></a></li>
<li>
<a href=""><span class="glyphicon glyphicon-shopping-cart"></span></a>
<div class="shopping">
<div>$0.00(0)</div>
<button>空</button>
</div>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</div>
</header>
<script src="js/jquery.min.js" type="text/javascript"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
css样式为
#page-head{
height:50px;
width:100%;
background: #5D4B33 ;
}
#page-head+* {margin-top: 50px;}
.navbar{
width:1200px;
margin:0 auto;
background:#5D4B33 ;
border:none;
}
.navbar-toggle{
margin-left:150px;
position: absolute;
float:left;
}
.navbar-right{
margin-right:130px;
}
.navbar-left{
}
.navbar-default .navbar-nav >li >a{
color:#fff;
border-left:1px solid #666;
}
.navbar-default .navbar-left >li >a:hover{
background:#F07818;
}
.navbar-collapse .dropdown .dropdown-menu{
width:400px;
height:200px;
background:#fff;
}
.navbar-collapse .dropdown .dropdown-menu >li{
display: inline-block;
float: left;
width:100px;
margin-left:15px;
}
.navbar-collapse .dropdown .dropdown-menu >li> ul li:nth-child(1) {
margin-top:15px;
margin-bottom:-5px;
}
.navbar-collapse .dropdown .dropdown-menu >li> ul li:nth-child(1)>a{
color:orange;
}
.navbar-collapse .dropdown .dropdown-menu >li> ul li{
line-height:30px;
}
代码这样写,导航的右边因为有了子菜单之后,把导航条撑开了,那接下来要怎么设置,可以让导航条变成作业中那种效果?
正在回答 回答被采纳积分+1
- 参与学习 人
- 提交作业 2198 份
- 解答问题 5012 个
如果你有web端基础,既想进阶,又想进军移动端开发,那就来吧,我们专题为你带来的课程有HTML5、CSS3、移动基础、响应式、bootstrap、less等,让你在前端道路上畅通无阻!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星