老师,您好~
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>好好学习</title> <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> <div id="topback"></div> <a class="back-up-btn btn btn-default btn-lg" href="#topback" aria-label="返回顶部"> <span class="glyphicon glyphicon-menu-up" aria-hidden="true"></span> </a> <header id="page-head"> <div class="container head-box"> <nav class="navbar navbar-default"> <div class="container-fluid"> <!-- Brand and toggle get grouped for better mobile display --> <div id="head-logo"><img src="images/index_05.png"></div> <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> <!-- 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="#">首页</a></li> <li><a href="#">产品</a></li> <li><a href="#">关于</a></li> </ul> <div class="nav-tell hidden-xs hidden-sm hidden-md">4007-888888</div> </div><!-- /.navbar-collapse --> </div><!-- /.container-fluid --> </nav> </div> </header> <section class="banner"> <img src="images/index_12.png" alt=""> </section> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <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>
@charset "utf-8";
/*css document*/
#page-head{
width: 100%;
height: 100px;
background: #f9f9f9;
position: fixed;
top:0;
z-index: 99;
}
#page-head+*{
margin-top: 100px;
}
.navbar-default{
border: 0;
border-bottom: 0;
}
#head-logo{
float: left;
margin-top: 15px;
}
.nav-tell{
float: right;
background: url("../images/index_08.png");
width: 186px;
height: 47px;
line-height: 47px;
font-size: 16px;
text-indent: 50px;
color: #ef200d;
margin-top: 27px;
}
.navbar-nav li{
width: 98px;
height: 100px;
text-align: center;
font-size: 16px;
margin-left: 40px;
}
.navbar-nav li a{
padding: 0;
margin: 0;
line-height: 100px;
color: #666;
}
.navbar-nav li.active a{
background: url("../images/index_02.png");
}
@media (max-width:992px){
.navbar-nav{
margin-left:0;
}
}
@media (max-width: 768px) {
.navbar-toggle{
margin-top: 22px
}
#head-logo{
margin-top: 8px;
}
#page-head{
height: 80px;
}
#page-head+*{
margin-top: 80px;
}
.navbar-nav{
margin-left: 0;
width: 100%;
}
.navbar-nav li{
width: 100%;
margin-left: 0;
height: 50px;
}
.navbar-nav li a{
line-height: 50px;
}
.navbar-collapse{
padding: 0;
}
}
banner上面会有100px的空白,怎么处理啊?
正在回答 回答被采纳积分+1
同学,你好。和老师的代码做对比是可以的,但是要建立在你和老师的代码是一样的基础上。目前,你的代码还没有写完,和老师的不是一模一样的。
这个空隙出现的罪魁祸首其实你的代码中最上面的a标签:
老师的代码是把这个标签固定到了屏幕右下角,因为你现在没有给她设置定位,所以它还在文档流中,当你设置了margin-top:100之后,这个margin会从a标签下接着排列,不是从最顶部开始排列的,
有两种解决方案:
1、先把a标签注释了,等后面你写它的样式的时候再放出来,设置定位之后也能正常
2、现在就把a标签的样式给设置了,定位到右下角
不然a标签会影响到上面模块的正常布局。
如果帮助到了你,欢迎采纳!
- 参与学习 人
- 提交作业 2198 份
- 解答问题 5012 个
如果你有web端基础,既想进阶,又想进军移动端开发,那就来吧,我们专题为你带来的课程有HTML5、CSS3、移动基础、响应式、bootstrap、less等,让你在前端道路上畅通无阻!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星