swiper 大图预览

<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no minimal-ui">
<meta charset="UTF-8">
<title>Document</title>
<style>
.showBigImg {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,.6);
  z-index: 999;
}
.showBigImg .closeBigImg {
  position: absolute;
  right: 35px;
  top: 35px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #000;
  text-align: center;
  line-height: 45px;
  font-size: 45px;
  color: #fff;
  z-index: 9999;
  user-select: none;
}
.showBigImg .showBigImgWrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.showBigImg .showBigImgWrap .allImgBox {
  position: relative;
  width: 100%;
  height: 100%;
}
.showBigImg .showBigImgWrap .allImgBox .imgIte {
  float: left;
  width: 100%;
  height: 100%;
  text-align: center;
}
.showBigImg .showBigImgWrap .allImgBox .imgIte span {
  display: inline-block;
  width: 0;
  height: 100%;
  vertical-align: middle;
}
.showBigImg .showBigImgWrap .allImgBox .imgIte img {
  max-width: 90%;
  max-height: 90%;
  vertical-align: middle;
}
.small-img img{
  width: 150px;
}
</style>
</head>
<body>
<div class="small-img">

<img src="//cdn.attach.qdfuns.com/notes/pics/201710/13/093715yf2jt47tttj9lyfj.jpg" alt="">

<img src="//cdn.attach.qdfuns.com/notes/pics/201710/13/092835ebbkfzjtb4okwj2b.jpg" alt="">

<img src="//cdn.attach.qdfuns.com/notes/pics/201710/13/092835beqzk6kyjkbwr5bw.jpg" alt="">

<img src="//cdn.attach.qdfuns.com/notes/pics/201710/13/092835nshkii0i2k0dsikn.jpg" alt="">

<img src="//cdn.attach.qdfuns.com/notes/pics/201710/13/093653k6ztcd7x7czebkfh.jpg" alt="">

</div>

<div class="showBigImg">
    <div class="closeBigImg">
        ×
    </div>
    <div class="showBigImgWrap swiper-container">
        <div class="allImgBox swiper-wrapper">
            <div class="imgIte swiper-slide">
                <span></span><img src="img/slide1.png" alt="">
            </div>
        </div>
        <a href="javascript:;" class="swiper-button-prev"></a>
        <a href="javascript:;" class="swiper-button-next"></a>
    </div>
</div>


<script>

    var myswiper = new Swiper('.showBigImgWrap',{
        prevButton:'.swiper-button-prev',
        nextButton:'.swiper-button-next'
    });

    var outwrap = $('.showBigImg');
        var close = $('.closeBigImg');
    var box = $('.allImgBox');

        close.click(function () {
            outwrap.fadeOut();
        });

    //BigImg代码生成
    function BigImgSlide(srcArr,posi){

        outwrap.fadeIn();

        var str = '';
        for(var i=0; i<srcArr.length; i++){
            str += '<div class="imgIte swiper-slide"><span></span><img src="'+ srcArr[i]+'" alt=""></div>';
        }
        box.html(str);

        var imgIte = $('.imgIte');
        imgIte.css({
            width: window.innerWidth,
            height: window.innerHeight
        });

        myswiper.update();
        myswiper.slideTo(posi, 0);
    }

    //图片点击
    $(function () {
        var img = $('.small-img img');
        img.click(function () {
            var arr = [];
            img.each(function () {
                arr.push($(this).attr('src'));
            });
            BigImgSlide(arr, img.index(this));
        });
    });

</script>
</body>
</html>

进群领取相关资料598399936 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值