为什么在宽度过小时导航和图片会重叠,在宽带768到856之间导航会变成两行?
<!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/css2.css" rel="stylesheet" type="text/css"> <link href="css/layout2.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> <nav class="navbar navbar-default"> <div class="container-fluid header-box"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header header-tit"> <button type="button" class="navbar-toggle collapsed btn" 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 logo" href="#"><img src="images/index_05.png"></a> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse header-main" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li class="on"><a href="#">首页 <span class="sr-only">(current)</span></a></li> <li><a href="#">产品</a></li> <li><a href="#">我们</a></li> </ul> <div class="nav navbar-nav navbar-right header-tell hidden-xs hidden-sm hidden-md"> 4008-888888 </div> </div><!-- /.navbar-collapse --> </div><!-- /.container-fluid --> </nav> </header> <section class="pic ser-banner"> <img src="images/index_12.png"> </section> <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> <script src="js/script.js"></script> </body> </html>
@charset "utf-8"; /* CSS Document */ header{ position: fixed; width: 100%; top: 0; z-index: 99; } header+* {margin-top: 1rem;} .header-box{ height: 1rem; } .header-main ul li a{ height: 1rem; line-height: 1rem; padding: 0 0.3rem; font-size: 0.16rem; } .header-main ul .on{ background:url(../images/index_02.png); } .header-main ul{ margin-left:0.8rem; } .header-main ul li{ margin:0 0.2rem; } .logo{ float:left; height: 1rem; } .header-tit img{ margin-left: 1rem; height: 0.7rem; } .header-tell{ background:url(../images/index_08.png) no-repeat center 48%; width:1.86rem; height:1rem; line-height:1rem; font-size:0.16rem; color:#ef200d; margin-right: 1rem; padding-left: 0.5rem; } header .btn{ margin-top:0.3rem; } .ser-banner{ width:100%; text-align: center; } .ser-banner img{ max-width: 100%; } @media (max-width:768px){ .header-main{ width: 100%; margin:0; padding: 0; text-align: center; float: left; } .header-main ul{ margin:0; width: 100%; } .header-main ul li{ margin:0; width:100%; } .header-main ul li a{ width:100%; height: 0.5rem; line-height: 0.5rem; } }
(function(doc, win) { var docEl = doc.documentElement, resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', recalc = function() { var clientWidth = docEl.clientWidth; if (!clientWidth) return; if (clientWidth >= 800) { docEl.style.fontSize = '100px'; } else { docEl.style.fontSize = 100 * (clientWidth / 800) + 'px'; } }; if (!doc.addEventListener) return; win.addEventListener(resizeEvt, recalc, false); doc.addEventListener('DOMContentLoaded', recalc, false); recalc(); })(document, window);
0
收起
正在回答 回答被采纳积分+1
3回答
响应式开发与常用框架 2018
- 参与学习 人
- 提交作业 2198 份
- 解答问题 5012 个
如果你有web端基础,既想进阶,又想进军移动端开发,那就来吧,我们专题为你带来的课程有HTML5、CSS3、移动基础、响应式、bootstrap、less等,让你在前端道路上畅通无阻!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星