例子:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
<link rel="stylesheet" type="text/css" href="css/swiper.css"/>
<style type="text/css">
html,body{
height: 100%;
}
.swiper-container {
height: 100%;
text-align: center;
}
.swiper-container .swiper-wrapper div:nth-child(1){
background: pink;
}
.swiper-container .swiper-wrapper div:nth-child(2){
background: aqua;
}
.swiper-container .swiper-wrapper div:nth-child(3){
background: tomato;
}
.swiper-container .swiper-wrapper div:nth-child(4){
background: plum;
}
.swiper-container .swiper-wrapper div:nth-child(5){
background: bisque;
}
</style>
</head>
<body>
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
<div class="swiper-slide">Slide 4</div>
<div class="swiper-slide">Slide 5</div>
</div>
<!-- 如果需要分页器 -->
<div class="swiper-pagination"></div>
<!-- 如果需要导航按钮 -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
</body>
<script type="text/javascript" src="js/swiper.js"></script>
<script type="text/javascript">
var mySwiper = new Swiper ('.swiper-container', {
// 如果需要分页器
pagination: {
el: '.swiper-pagination',
},
speed:300,
autoplay: {
disableOnInteraction: false,
},
// 如果需要前进后退按钮
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
}
})
</script>
</html>