<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.0.2/css/swiper.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.0.2/js/swiper.min.js"></script>
</head>
<style>
.dd {
width: 100%;
height: 500px;
}
.d1 {
background-color: #dd2628;
}
.d2 {
background-color: #51abf7;
}
.d3 {
background-color: green;
}
.swiper-container {
width: 100%;
}
.swiper-slide {
width: 80%;
transform: scale(0.9);
}
.swiper-slide-active {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
transform: scale(1);
}
</style>
<body>
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide"><div class="d1 dd"></div></div>
<div class="swiper-slide"><div class="d2 dd"></div></div>
<div class="swiper-slide"><div class="d3 dd"></div></div>
</div>
<div class="swiper-pagination"></div>
</div>
<script>
var mySwiper = new Swiper('.swiper-container', {
loop : true,
centeredSlides: true,
slidesPerView: "auto",
initialSlide: 1,
pagination: {
el: '.swiper-pagination',
},
})
</script>
</body>
</html>
效果图
1.png
网友评论