swiper 定义放多少张图片_Swiper滚动图片显示当前图片是第几张图片

展开全部

/*单个切换的幻灯片e68a843231313335323631343130323136353331333339653662 s*/

.banner{

position: relative;

overflow: hidden;

}

.banner-publicHt{

height: 396px;

}

.img-box{

display: inline-block;

width: 100%;

}

.swiper-slide {

text-align: center;

font-size: 36px;

background: #fff;

/* Center slide text vertically */

display: -webkit-box;

display: -ms-flexbox;

display: -webkit-flex;

display: flex;

-webkit-box-pack: left;

-ms-flex-pack: left;

-webkit-justify-content: left;

justify-content: left;

-webkit-box-align: left;

-ms-flex-align: left;

-webkit-align-items: left;

align-items: left;

}

.banner .swiper-slide img{

width: 100%;

}

.banner .swiper-pagination-bullet-active{

background: url("/img/off.png") no-repeat;

}

.banner .swiper-pagination-bullet{

background: url("/img/on.png") no-repeat;

}

.banner .swiper-container-horizontal>.swiper-pagination{

left: 160px;

}

.num-check{

position: absolute;

right: 0;

bottom: 0px;

background-color: #000;

opacity: 0.7;

width: 100%;

height: 50px;

z-index: 998;

}

.num-choose{

position: absolute;

right: 5%;

bottom: 0px;

color: #FCFBFB;

font-size: 22px;

display: inline-block;

width: 90%;

height: 50px;

line-height: 50px;

z-index: 999;

text-align: right;

}

/*单个切换的幻灯片 e*/

$(function(){

$(".checkLength").html(1);

/*单个切换的幻灯效果*/

var swiper = new Swiper('.banner .swiper-container', {

pagination: '.banner .swiper-pagination',

paginationClickable: true,

spaceBetween: 30,

/*每隔5秒就进行一次图片切换*/

autoplay:5000,

// direction: 'vertical',

/*用户操作之后(swipes,arrow以及pagination 点击)autoplay不会被禁掉*/

autoplayDisableOnInteraction:false,

onSlideChangeStart: function(swiper){

$(".checkLength").html(swiper.activeIndex+1);

}

});

/*获取图片长度*/

var imgAllLength = $(".swiper-slide .banner-publicHt").length;

console.log(imgAllLength);

$(".allImgLength").html(imgAllLength);

/*图片报错或者为空的时候默认现在这张图片*/

$(".banner-publicHt").on('error',function(){

$(this).prop('src','../swiper/img/banner1.jpg');

})

})

已赞过

已踩过<

你对这个回答的评价是?

评论

收起

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值