swiper 自动图片无限轮播实现代码自动图片无限轮播实现代码
今天移动端正好需要图片触摸滑动效果实现代码,基于swiper实现,需要的朋友可以参考下
完整代码
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="swiper/css/swiper-3.4.2.min.css" rel="external nofollow" >
<script src="swiper/js/swiper-3.4.2.min.js"></script>
<style type="text/css">
.swiper-container {
width: 900px;
height: 300px;
}
</style>
</head>
<body>
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide box1"><img src="img/a.jpg"></div>
<div class="swiper-slide box2" ><img src="img/b.jpg"></div>
<div class="swiper-slide box3"><img src="img/c.jpg"></div>
</div>
<!-- 如果需要分页器 -->
<div class="swiper-pagination"></div>
<!-- 如果需要导航按钮 -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
<!-- 如果需要滚动条 -->
<!--<div class="swiper-scrollbar"></div>-->
</div>
</div>
<script>
var mySwiper = new Swiper ('.swiper-container', {
direction: 'horizontal',
loop: true,
// 如果需要分页器
pagination: '.swiper-pagination',
// 如果需要前进后退按钮
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
autoplay : 1000,
speed:100,
// 如果需要滚动条
// scrollbar: '.swiper-scrollbar',
effect : 'coverflow',
slidesPerView: 3,
centeredSlides: true,
coverflow: {
rotate: 30,
stretch: 10,
depth: 60,
modifier: 2,
slideShadows : true
}
})
</script>
</body>
</html>
如何使用如何使用swiper写轮播写轮播
之前大家都写过轮播图吧,相信在写轮播图的过程中也因为当中的某些细节烦恼过吧,接下来我给大家讲述一个方便快捷的轮
播图吧!
Swiper常用于移动端网站的内容触摸滑动
评论5