1、媒体查询
用法:@media (min-width:像素值) and (max-width: 像素值) {}
外链式:
2、bootsrap使用
引入boostrap.css文件
<link
rel="stylesheet"
href="./bootstrap-3.4.1-dist/css/bootstrap.min.css"
/>
引入jq+js文件
<script src="./js/jquery.js"></script>
<script src="./bootstrap-3.4.1-dist/js/bootstrap.js"></script>
布局以及样式参考如图:
今日案例:AlloyTeam响应式网页
考察点:boostrap运用 媒体查询 less
目前做到:导航栏以及轮播图区域
<!-- 导航 -->
<nav class="myNav navbar navbar-default navbar-fixed-top">
<div class="container">
<!-- 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="#">
<img src="./images/logo.png" alt="">
</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-right">
<li><a href="#">首页</a></li>
<li><a href="#">博客</a></li>
<li><a href="#">GitHub</a></li>
<li><a href="#">Tweb Conf</a></li>
<li><a href="#">SuperStar</a></li>
<li><a href="#">Web前端</a></li>
<li><a href="#">关于</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<!-- 轮播图 -->
<div id="carousel-example-generic" class="mycarousel carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
<li data-target="#carousel-example-generic" data-slide-to="3"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="./uploads/banner_1.jpg" alt="...">
<!-- <div class="carousel-caption">
...
</div> -->
</div>
<div class="item">
<img src="./uploads/banner_2.jpg" alt="...">
<!-- <div class="carousel-caption">
...
</div> -->
</div>
<div class="item">
<img src="./uploads/banner_3.jpg" alt="...">
<!-- <div class="carousel-caption">
...
</div> -->
</div>
<div class="item">
<img src="./uploads/banner_4.jpg" alt="...">
<!-- <div class="carousel-caption">
...
</div> -->
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
.myNav {
height: 70px;
background-color: transparent;
border: none;
.navbar-nav {
margin-top: 16px;
li {
a {
color: #ffffffa6;
&:hover {
color: #ffffffa6;
}
}
}
}
}
.mycarousel {
height: 400px;
.carousel-inner {
img {
width: 100%;
height: 400px;
// 剪裁图片,防止图片变形
object-fit: cover;
}
}
}
//导航条的媒体查询
@media (max-width: 992px) {
.myNav {
background-color: #26282c;
.navbar-collapse {
border: 0px;
box-shadow: none;
background-color: #26282c;
margin-top: 10px;
}
}
}
@media (max-width: 768px) {
body {
padding-top: 70px;
}
.mycarousel {
height: 250px;
.carousel-inner {
img {
height: 250px;
}
}
}
}
~明天继续加油丫