使用bootstrap3navbar时很多默认的样式如果更改移动端下面的显示就会出问题,这个怎么破?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>2-7bootstrap</title>
<link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.css">
<link rel="stylesheet" href="bootstrap-4.0.0/dist/css/bootstrap.css">
<link rel="stylesheet" href="css/2-7bootstrap.css">
<script src="js/jquery-3.3.1.js"></script>
<script src="bootstrap-4.0.0/assets/js/vendor/popper.min.js"></script>
<script src="bootstrap-4.0.0/dist/js/bootstrap.bundle.js"></script>
<script src="bootstrap-4.0.0/dist/js/bootstrap.js"></script>
</head>
<body>
<div class="container">
<div class="row header">
<div class="col-md-3 col-sm-2 col-xs-1 text-right logo">imooc</div><!--imooc标题栏-->
<div class="col-md-5 col-sm-5 col-xs-5">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link navbar-brand" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
</ul>
</div>
</nav>
<!--<ul class="nav">
<li class="nav-item">
<a class="nav-link active" href="#">首页</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">生日</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">婚礼</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">专用</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">商铺</a>
</li>
</ul>--><!--这个写出来没有移动端的那个点击按钮展开菜单栏的效果-->
</div><!--中间可移动变换导航栏,使用bootstrap3框架-->
<div class="col-md-4 col-sm-5 col-xs-2">
<span class="a1 glyphicon glyphicon-search " data-container="body" data-toggle="popover" data-placement="bottom" data-content="该怎么切换呢?" href="#1"></span>
<span class="a1 glyphicon glyphicon-user" href="#1"></span>
<span class="a1 glyphicon glyphicon-shopping-cart" href="#1"></span>
</div><!--右侧固定导航栏-->
</div>
<div class="row banner"></div>
<div class="row gallery"></div>
<div class="row subscript"></div>
<div class="row footer-bottom"></div>
<div class="row footer"></div>
</div>
<script>
$(function () {
$('[data-toggle="popover"]').popover()
})
</script>
</body>
</html>
/*html代码*/
*{
margin:0;
padding: 0;
}
body{
font-size: 16px;
}
.container{
max-width: 100%;
margin: 0;
}
.header{
flex-wrap: nowrap;
height: 3.6rem;
background:#5D4B33;
}
.header div:nth-child(1){
line-height: 3.6rem;
}
.header .logo{
font-size:2.4rem;
line-height: 3.2rem;
text-transform: uppercase;
color: #FFFFFF;
}
.header .a1{
display: inline-block;
padding: 0 1.2rem;
color: white;
font-size:1.6rem;
height: 3.5rem;
line-height: 3.5rem;
border-left: 1px solid #999999;
box-sizing: border-box;
}
.nav .nav-item .nav-link{
color: #FFFFFF;
height:3.6rem;
}
.nav .nav-item .active{
background: #f07818;
}
.nav .nav-item .nav-link:hover{
background: #f07818;
box-shadow: -1px 0 2px 0 rgba(0,0,0,0.4);
}
@media screen and (max-width:576px){
body{
font-size: 20px;
}
.header{
height: 4rem;
}
.header div:nth-child(1){
line-height: 4rem;
}
.header .a1{
padding: 0 0.4rem;
font-size:1.4rem;
height:3.9rem;
line-height:4rem;
}
}
@media screen and (max-width:376px){
body{
font-size: 20px;
}
.header{
height: 4rem;
}
.header div:nth-child(1){
font-size: 2rem;
line-height: 4rem;
}
.header .a1{
padding: 0 0.3rem;
font-size:0.3rem;
height:3.9rem;
line-height:4rem;
}
}/*媒体查询phone设备,改变body font-size来响应相对单位rem*/
正在回答 回答被采纳积分+1
- 参与学习 人
- 提交作业 2198 份
- 解答问题 5012 个
如果你有web端基础,既想进阶,又想进军移动端开发,那就来吧,我们专题为你带来的课程有HTML5、CSS3、移动基础、响应式、bootstrap、less等,让你在前端道路上畅通无阻!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星