头像

swiper轮播问题之二:默认显示3张图片,中间显示全部两边显示部分

2018-11-02 09:26:33 来源:PHP代码   浏览()   评论 ( 0 )   

项目遇到比较有点要求的轮播图,默认显示3张图片,中间显示全部,两边显示部分。

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta content="target-densitydpi=320,width=750,user-scalable=no" name="viewport">
<meta content="no" name="apple-touch-fullscreen">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<!--<meta name="viewport" content="width=750, initial-scale=1, user-scalable=no">-->
<title>demo</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/3.4.2/css/swiper.min.css">
<!--<link rel="stylesheet" href="swiper.min.css">-->
<style>
.swiper{
box-sizing: border-box;
position: relative;
padding: 20px 0 53px;
background-color: #f9f9f9;
}
.swiper-container {
margin-top: 20px;
width: 750px;
height: 320px;
margin-bottom: 53px;
overflow: visible!important;
}
.swiper-container .swiper-wrapper .swiper-slide{ width: 620px; border-radius: 20px;}
.swiper-container .swiper-wrapper .swiper-slide img{width: 100%; height: 320px; border-radius: 20px;}
.swiper-container .swiper-wrapper .swiper-slide-prev{ margin-top: 18px; height: 284px!important;}
.swiper-container .swiper-wrapper .swiper-slide-prev img{ height: 284px!important;}
.swiper-container .swiper-wrapper .swiper-slide-next{ margin-top: 18px; height: 284px!important;}
.swiper-container .swiper-wrapper .swiper-slide-next img{ height: 284px!important;}
.swiper-container .swiper-wrapper .swiper-slide-active{ width: 620px;}
.swiper-pagination{
bottom: -30px!important;
}
.swiper-pagination .swiper-pagination-bullet{width: 12px; height: 12px; background: #ff1e1e;}
.swiper-pagination .swiper-pagination-bullet-active{width: 21px; height: 12px; background: #e75230; border-radius: 6px;}
</style>
<script src="swiper.min.js"></script>
<!--<script src="../js/swiper.min.js"></script>-->
</head>
<body>
<div>
<div>
<div>
<div><img src="../images/banner_default.jpg"/></div>
<div><img src="../images/3.jpg"/></div>
<div><img src="../images/po.jpg"/></div>
</div>
<!-- 如果需要分页器 -->
<div></div>
</div>
</div>
<script>
var mySwiper = new Swiper ('.swiper-container', {
direction: 'horizontal',
loop: true,
autoplay: 5000,
slidesPerView: "auto",
centeredSlides:true,
spaceBetween: 20,
// 如果需要分页器
pagination: '.swiper-pagination',
})
</script>
</body>
</html>


标签: JavaScript
声明:转载请注明来源(PHP代码)并保留原文链接:http://www.phpdaima.com//master-122.html
广告不存在
评论0

后面还有条评论,点击查看>>

温馨提示:为规范评论内容,垃圾评论一律封号...