效果图:
index.html
<!DOCTYPE html>
<html lang="en">
<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">
<link rel="stylesheet" href="./css/normalize.css">
<link rel="stylesheet" href="./css/index.css">
<link rel="stylesheet" href="./css/swiper.min.css">
<title>Document</title>
</head>
<body>
<section class="warp">
<!-- 头部区域 -->
<header class="header">黑马面面</header>
<!-- 导航栏部分 -->
<nav class="nav">
<a href="#" class="item">
<img src="./icons/icon1.png" alt="" />
<span>HR面试</span>
</a>
<a href="#" class="item">
<img src="./icons/icon2.png" alt="" />
<span>笔试</span>
</a>
<a href="#" class="item">
<img src="./icons/icon3.png" alt="" />
<span>技术面试</span>
</a>
<a href="#" class="item">
<img src="./icons/icon4.png" alt="" />
<span>模拟面试</span>
</a>
<a href="#" class="item">
<img src="./icons/icon5.png" alt="" />
<span>面试技巧</span>
</a>
<a href="#" class="item">
<img src="./icons/icon6.png" alt="" />
<span>薪资查询</span>
</a>
</nav>
<!-- go模块 -->
<section class="go">
<img src="./images/go.png" alt="" />
</section>
</section>
<section class="content">
<!-- 头部 -->
<div class="con-hd">
<h4>
<span class="icon"><img src="./icons/i2.png" alt="" /></span>
就业指导
</h4>
<a href="#" class="more">更多>></a>
</div>
<!-- 旋转木马轮播图模块 -->
<div class="get_job_focus">
<div class="swiper-container get_job_fo">
<div class="swiper-wrapper">
<div class="swiper-slide">
<a href="#"><img src="./images/pic.png" alt="" /></a>
<p>老师教你应对面试技巧</p>
</div>
<div class="swiper-slide">
<a href="#"><img src="./images/ldh.jpg" alt="" /></a>
<p>老师教你应对面试技巧</p>
</div>
<div class="swiper-slide">
<a href="#"><img src="./images/3.jpg" alt="" /></a>
<p>老师教你应对面试技巧</p>
</div>
</div>
<!-- Add Arrows 根据需求这个代码放到 container外面 添加左右箭头-->
<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>
</div>
</section>
<section class="content study_con">
<!-- 头部 -->
<div class="con-hd">
<h4>
<span class="icon"><img src="./icons/i2.png" alt="" /></span>
充电学习
</h4>
<a href="#" class="more">更多>></a>
</div>
<div class="study">
<!-- Swiper -->
<div class="swiper-container study_fo">
<div class="swiper-wrapper">
<div class="swiper-slide">
<img src="./images/pic1.png" alt="" />
<h5>说低调英语,告别中式英语</h5>
<p>156人学习</p>
</div>
<div class="swiper-slide">
<img src="./images/pic2.png" alt="" />
<h5>说低调英语,告别中式英语</h5>
<p>156人学习</p>
</div>
<div class="swiper-slide">
<img src="./images/pic1.png" alt="" />
<h5>说低调英语,告别中式英语</h5>
<p>156人学习</p>
</div>
<div class="swiper-slide">
<img src="./images/pic1.png" alt="" />
<h5>说低调英语,告别中式英语</h5>
<p>156人学习</p>
</div>
</div>
<!-- Add Pagination -->
<div class="swiper-pagination"></div>
</div>
</div>
</section>
<footer class="footer">
<a href="#" class="item">
<img src="./icons/home.png" alt="" />
<p>首页</p>
</a>
<a href="#" class="item">
<img src="./icons/ms.png" alt="" />
<p>模拟面试</p>
</a>
<a href="#" class="item">
<img src="./icons/net.png" alt="" />
<p>技术面试</p>
</a>
<a href="#" class="item">
<img src="./icons/user.png" alt="" />
<p>我的首页</p>
</a>
</footer>
<script src="./js/flexible.js"></script>
<!-- 比如引入js文件 -->
<script src="./js/swiper.min.js"></script>
<script>
// 第一个函数里面是 就业指导轮播图
(function () {
var swiper = new Swiper(".get_job_fo", {
// 能够显示的 slider的个数
slidesPerView: 2,
// 每一个slide之间的距离
spaceBetween: 30,
centeredSlides: true,
loop: true,
// 添加左右箭头
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
});
})();
// 第二个函数的轮播图
(function () {
// 如果有多个轮播图最好修改下 swiper-container
var swiper = new Swiper(".study_fo", {
// 我们可以可以看看到的是 2个半
slidesPerView: 2.5,
centeredSlides: true,
spaceBetween: 20,
loop: true,
});
})();
</script>
</body>
</html>
index.less
a{
text-decoration: none;
color: grey;
}
body{
min-width:320px;
max-width: 750px;
margin: 0px auto;
}
@media screen and (min-width:750px) {
html{
font-size: 39x !important;
}
}
.warp{
background-color: #fff;
}
.header{
height: 2.1333rem;
border: 1px solid purple;
text-align: center;
line-height: 2.1333rem;
font-size: .8974rem;
}
.nav{
display: flex;
flex-wrap: wrap;
margin: 1.1538rem 1.5385rem;
.item{
width: 33.3%;
display: flex;
flex-direction: column;
text-align: center;
align-items: center;
font-size: .641rem;
&:nth-child(-n+3){
margin-bottom: 1.5897rem;
}
img{
width: 3.5641rem;
height: 3.5641rem;
}
}
}
.go{
margin: 0px .2564rem;
border-radius: 10px;;
padding-bottom: 1.1026rem;
}
.content {
padding: 1.066667rem 0.64rem;
background-color: #fff;
margin-top: 0.266667rem;
.con-hd {
display: flex;
justify-content: space-between;
height: 1.013333rem;
line-height: 1.013333rem;
margin-bottom: 0.906667rem;
h4 {
margin: 0;
font-size: 0.746667rem;
color: #333333;
.icon {
display: inline-block;
width: 1.013333rem;
height: 1.013333rem;
// 添加这个代码,可以让后面的文字垂直居中
vertical-align: middle;
}
}
.more {
font-size: 0.586667rem;
color: #999999;
}
}
}
.get_job_focus{
position: relative;
.swiper-container {
// width: 100%;
height: 100%;
// 根据需求把宽度定位 540px
width: 13.8462rem
}
}
.swiper-slide {
text-align: center;
font-size: 18px;
background: #fff;
/* Center slide text vertically */
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
// 竖向显示
flex-direction: column;
/* Center slide text vertically */
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
transition: 300ms;
// 其余的兄弟是 0.8
transform: scale(0.8);
opacity: 0.4;
a {
width: 9.013333rem;
height: 10.026667rem;
img {
width: 100%;
height: 100%;
}
}
p {
width: 9.013333rem;
font-size: 0.666667rem;
margin-top: 0.64rem;
color: #333;
}
}
// 当前选中的 slide 中间那个
.swiper-slide-active,
.swiper-slide-duplicate-active {
transform: scale(1);
z-index: 999;
opacity: 1;
}
.swiper-button-next,
.swiper-button-prev {
outline: none;
&:after {
font-size: 1.066667rem;
color: #333;
}
}
.study_con {
padding-bottom: 3.733333rem;
}
// 学习模块的轮播图
.study {
.study_fo {
padding: 0.266667rem;
}
.swiper-slide {
font-size: 18px;
background: #fff;
width: 7.4359rem;
height: 8.7179rem;
background-color: #fff;
border-radius: 0.266667rem;
box-shadow: 0 0px 10px rgba(0, 0, 0, 0.1);
h5 {
font-size: 0.693333rem;
margin: 0.533333rem 0;
font-weight: 400;
padding: 0 0.266667rem;
}
p {
font-size: 0.693333rem;
color: #ff4400;
padding: 0 0.266667rem;
}
}
}
.footer{
background-color: #fff;
border-top: 1px solid purple;
position: fixed;
height:2.8205rem;
left: 0px;
bottom: 0px;
width: 100%;
z-index: 1;
display: flex;
padding-top: .4872rem;
.item{
display: flex;
flex-direction: column;
flex: 4;
align-items: center;
justify-content: center;
img{
width: 1rem;
height: 1.0513rem;
}
p{
margin-top: .2821rem;
font-size: .5641rem;
}
}
}