老师我的导航缩小后 右边的空隙怎么解决
<!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.0,maximum-scale=1.0,user-scalable=no">
<title>2-7作业</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/2-7.css">
</head>
<body>
<header>
<div class="container">
<nav class="navbar navbar-default">
<div class="container-fluid ">
<a href="#"><img src="img/logo.png"></a>
<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>
</div>
<div class="center collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav nav-tabs">
<li role="presentation" class="dropdown">
<a class="dropdown-toggle active" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
首页
</a>
</li>
<li role="presentation" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
生日<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<ul class="left">
<li class="ti">关系</li>
<li>朋友</li>
<li>爱人</li>
<li>姐妹</li>
</ul>
<ul class="left">
<li class="ti">风味</li>
<li>巧克力</li>
<li>水果</li>
</ul>
</ul>
</li>
<li role="presentation" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
婚礼<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<ul class="left">
<li class="ti">关系</li>
<li>朋友</li>
<li>爱人</li>
<li>姐妹</li>
</ul>
<ul class="left">
<li class="ti">风味</li>
<li>巧克力</li>
<li>水果</li>
</ul>
<ul class="left">
<li class="ti">主旋律</li>
<li>心形</li>
<li>卡通</li>
</ul>
</ul>
</li>
<li role="presentation" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
专用<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<ul class="left">
<li class="ti">关系</li>
<li>朋友</li>
<li>爱人</li>
<li>姐妹</li>
</ul>
<ul class="left">
<li class="ti">风味</li>
<li>巧克力</li>
<li>水果</li>
</ul>
</ul>
</li>
<li role="presentation" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
商铺<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<ul class="left">
<li class="ti">关系</li>
<li>朋友</li>
<li>爱人</li>
<li>姐妹</li>
</ul>
<ul class="left">
<li class="ti">风味</li>
<li>巧克力</li>
<li>水果</li>
</ul>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="tubiao">
<ul>
<li><a href="#"><span class="glyphicon glyphicon-search tupian"></span></a>
<div class="sousuo">
<form>
<input type="text" name="text"><button class="btn">搜</button>
</form>
</div>
</li>
<li><a href="#"><span class="glyphicon glyphicon-user tupian"></span></a>
<div class="biaodan">
<form>
<div class="form-group">
<label for="email">Email</label>
<input type="eamil" name="email" id="email" class="form-control">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="password" id="password" class="form-control">
</div>
<button class="button">登录</button>
<div class="check">
<input type="checkbox" name="jizhumima"><span>记住</span>
</div>
<div class="p">新用户 ? <span>注册 | </span>忘记密码?</div>
</form>
</div>
</li>
<li><a href="#"><span class="glyphicon glyphicon-shopping-cart tupian"></span></a>
<div class="kong">
<p>$0.00(0)</p>
<button class="btn btn-group-justified">空</button>
</div>
</li>
</ul>
</div>
</div>
</header>
<section></section>
<script type="text/javascript" src="js/jquery-1.12.4.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/2-7.js"></script>
</body>
</html>
* {
padding: 0px;
margin: 0px;
}
li {
list-style: none;
}
html {
font-size: 12px;
}
/*页头*/
header {
box-sizing: border-box;
width: 100%;
background-color: #5D4B33;
height: 4rem;
}
header img {
float: left;
width: 6rem;
height: 2.2rem;
margin-top: 0.9rem;
margin-right: 1rem;
}
header .center>ul {
float: left;
}
header .nav-tabs>li {
background-color: #5D4B33;
}
header .nav-tabs>li>a {
border-radius: 1px;
height: 4rem;
line-height: 2.2rem;
color: white;
}
header .center .nav-tabs>li>a .caret {
margin-left: 0.8rem;
}
header .dropdown-menu {
width: 28rem;
height: 12rem;
padding-top: 1rem;
padding-left: 1.5rem;
}
header a.dropdown-toggle:hover {
background-color: #F07818;
border: none;
}
header .dropdown-menu li {
line-height: 1.8rem;
padding-right: 4rem;
}
header .dropdown-menu .left {
float: left;
margin-right: 1.5rem;
}
header .dropdown-menu .left .ti {
color: #F07818;
border-bottom: 1px solid #ccc;
margin-bottom: 0.7rem;
}
header .dropdown-menu .left li:not(:first-child):hover {
cursor: pointer;
color: #F07818;
}
header .center .dropdown .active {
border: none;
background: #F07818;
}
header .center .nav .open>a,
header .center .nav .open>a:hover,
header .center .nav .open>a:focus {
background-color: #F07818;
border: none;
}
header .navbar-header button.navbar-toggle{
margin-right:48%;
background:#F07818;
border:none;
}
header .navbar-header .navbar-toggle .icon-bar{
background:#fff;
}
header .navbar-header button.navbar-toggle:hover,
header .navbar-header button.navbar-toggle:focus{
background:#F07818;
}
/*右侧*/
header .tubiao {
position:relative;
float: right;
width: 20%;
}
header nav.navbar.navbar-default{
float:left;
width: 80%;
background: #5D4B33;
border: none;
}
header .tubiao ul li {
float: left;
width: 33.33%;
}
header .tubiao ul li a {
display: block;
}
header .tubiao ul li .tupian {
height: 4rem;
color: #fff;
text-align: center;
line-height: 4rem;
}
header .tubiao .sousuo {
display: none;
padding-top: 1rem;
padding-left: 1.5rem;
position: absolute;
top: 4rem;
left: -16rem;
height: 6rem;
width: 19rem;
background: #fff;
border: 1px solid #ccc;
}
header .tubiao .sousuo::after {
content: '';
position: absolute;
top: -1.6rem;
left: 17rem;
width: 0rem;
height: 0rem;
border-top: 0.8rem transparent solid;
border-left: 0.8rem transparent solid;
border-right: 0.8rem transparent solid;
border-bottom: 0.8rem #fff solid;
}
header .tubiao .sousuo form {
height: 2.5rem;
overflow: hidden;
}
header .tubiao .sousuo input {
border: 1px solid #F07818;
width: 11rem;
height: 2.5rem;
}
header .tubiao .sousuo .btn {
border: none;
width: 3.5rem;
line-height: 0.9rem;
color: #fff;
height: 2.7rem;
border-radius: 0px;
background: #F07818;
}
header .tubiao .sousuo .btn {
border: none;
width: 4rem;
line-height: 0.9rem;
color: #fff;
height: 2.7rem;
border-radius: 0px;
background: #F07818;
}
header .tubiao .biaodan {
display: none;
border: 1px solid #ccc;
padding: 0.5rem 0.8rem 0.8rem;
width: 20rem;
height: 18.5rem;
position: absolute;
top: 4rem;
left: -12rem;
}
header .tubiao .biaodan::after {
content: '';
position: absolute;
top: -1.6rem;
left: 17rem;
width: 0rem;
height: 0rem;
border-top: 0.8rem transparent solid;
border-left: 0.8rem transparent solid;
border-right: 0.8rem transparent solid;
border-bottom: 0.8rem #fff solid;
}
header .tubiao .biaodan .form-group {
margin-bottom: 0.8rem;
}
header .tubiao .biaodan label {
font-size: 1rem;
}
header .tubiao .biaodan input {
height: 2.2rem;
}
header .tubiao .biaodan .button {
height: 2.2rem;
background: #F07818;
width: 100%;
line-height: 2.2rem;
border: 1px solid #F07818;
color: #fff;
}
header .tubiao .biaodan .button:hover {
background: #fff;
color: #F07818;
}
header .tubiao .biaodan .check {
height: 2rem;
position: relative;
}
header .tubiao .biaodan .check input {
width: 1rem;
display: inline-block;
}
header .tubiao .biaodan .check span {
font-size: 0.8rem;
position: absolute;
top: 0.9rem;
margin-left: 0.5rem;
}
header .tubiao .biaodan .p {
text-align: center;
margin-top: 1rem;
font-size: 0.7rem;
}
header .tubiao .biaodan .p span {
color: #F07818;
}
header .tubiao .kong {
display: none;
border: 1px solid #ccc;
position: absolute;
top: 4rem;
left: -4rem;
text-align: center;
padding: 1rem 0.5rem 0.3rem;
width: 15rem;
height: 8rem;
}
header .tubiao .kong::after {
content: '';
position: absolute;
top: -1.6rem;
left: 13rem;
width: 0rem;
height: 0rem;
border-top: 0.8rem transparent solid;
border-left: 0.8rem transparent solid;
border-right: 0.8rem transparent solid;
border-bottom: 0.8rem #fff solid;
}
header .tubiao .kong .btn {
border: 1px solid #F07818;
background: #F07818;
color: #fff;
}
header .tubiao .kong .btn:hover {
background: #fff;
color: #F07818;
}
header .container{
padding:0rem;
}
@media screen and (max-width:767px) {
html {
font-size: 12px;
}
header .nav-tabs>li {
float: none;
}
header .container .navbar-default .navbar-collapse .nav-tabs{
width: 100%;
text-align: center;
margin:0;
padding:0;
}
}
正在回答
你好同学,bootstrap样式比较多,有的时候改起来确实比较费劲,不要着急慢慢来。遇到问题在问答区域提问,老师都会一一帮助你解决的。右侧菜单是被挤下去的,所以可以使用定位,让它显示在导航右侧,如下:
也在媒体查询中重新设置一下它的位置
祝学习愉快 ,望采纳。
- 参与学习 人
- 提交作业 2198 份
- 解答问题 5012 个
如果你有web端基础,既想进阶,又想进军移动端开发,那就来吧,我们专题为你带来的课程有HTML5、CSS3、移动基础、响应式、bootstrap、less等,让你在前端道路上畅通无阻!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星