发现一个很好用的jquery控件
操作很简单
1.引入css
<link href="/Resources/style/swiper.min.css" rel="stylesheet" type="text/css" />
2.插入自定义样式
<style>
.swiper-container {
width: %;
height: %;
} .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;
-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;
} .banner img {
width: %;
max-height: 300px;
} </style>
3.设置轮播图片
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide"><div class="banner"><img src="/Resources/images/banner.jpg" onclick="alert('1')" /></div></div>
<div class="swiper-slide"><div class="banner"><img src="/Resources/images/shangping.jpg" /></div></div>
</div>
<!-- Add Pagination -->
<div class="swiper-pagination"></div>
<!-- Add Arrows -->
@*<div class="swiper-button-next"></div>
<div class="swiper-button-prev"></div>*@
</div>
4.底部引入JS文件以及配置
<script src="/Resources/js/swiper.min.js"></script>
<script>
var swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
paginationClickable: true,
spaceBetween: ,
centeredSlides: true,
autoplay: ,
autoplayDisableOnInteraction: false
});
</script>
参考资料:
http://www.swiper.com.cn/demo/senior/index.html