小编项目中需要中间大两边显示一部分的轮播图,之前查了很久文档,就是没找到想要的效果,后面自己结合swiper实现了一个(中间大两边显示一部分):
效果图:
```
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>轮播图练习</title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=0" />
<link rel="stylesheet" href="css/swiper.min.css">
<link rel="stylesheet" href="css/inedx.css" />
</head>
<body>
<div class="banner">
<div class="swiper-container" id='swiper'>
<div class="swiper-wrapper">
<div class="swiper-slide">
<a href="#">
<img src="img/banner3.jpg" alt="">
</a>
</div>
<div class="swiper-slide">
<a href="#">
<img src="img/banner3.jpg" alt="">
</a>
</div>
<div class="swiper-slide">
<a href="#">
<img src="img/banner3.jpg" alt="">
</a>
</div>
<div class="swiper-slide">
<a href="#">
<img src="img/banner3.jpg" alt="">
</a>
</div>
</div>
<div class="swiper-pagination top_right">
</div>
</div>
</div>
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/swiper.min.js"></script>
<script type="text/javascript" src="js/index-2.js"></script>
<script>
var swiper = new Swiper('.swiper-container', {
centeredSlides: true,
initialSlide :0,
loop:true,
paginationType : 'bullets',
slidesPerView: 'auto',
preventClicks : false,
autoplay:true,
speed:2000,
direction: 'horizontal',
spaceBetween: 1,
// 如果需要分页器
pagination: '.swiper-pagination',
});
</script>
</body>
</html>
```
网友评论