• swiper实现层叠轮播图


    先来两张示例图吧:

    以上呢就是示意图了;

    具体代码看下面吧

    1.首先: swiper的结构:

    <div class='swiper-container'>
      <div class='swiper-wrapper'>
        <div class='swiper-slide'>

        </div>
      </div>
    </div>

    这些肯定都知道,还是拿出来能实现上面效果图的代码吧

    //引入swiper的css样式,以下为个人路径
        <link rel="stylesheet" type="text/css" href="swiper/css/swiper.min.css" />

    css样式:

    /*展示区域*/
    .ours-main {
         100%;
        height: 28rem;
        margin-top: 3rem;
        display: flex;
        justify-content: center;
    }
    
    .ours-swiper {
        height: 100%;
         49.8%;
    }
    /*自定义swiper样式*/
    .swiper-container {
                    position: relative;
                     100%;
                    height: 100%;
                }
                .swiper-wrapper{
                     100%;
                    height: 100%;
                }
                .swiper-slide {
                    text-align: center;
                    height: 86%;
                    background: #CCCDCE;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    transition: 300ms;
                    transform: scale(0.8);
                }
                
                .swiper-slide-active,
                .swiper-slide-duplicate-active {
                    transform: scale(1);
                }
                .swiper-button-next,
                .swiper-button-prev{
                    display: none;
                }
                .swiper-slide-active{
                    z-index: 999 !important;
                }
                .swiper-slide-prev .s-right{
                    display: none;
                }
                .swiper-slide-prev .s-left{
                    margin-left: 35%;
                }
                .swiper-slide-prev {
                    background-color: #fff;
                }
                .swiper-slide-next{
                    background-color: #fff
                }
    /*要展示的div左侧样式*/
    .s-left{
         50%;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .s-l-block{
         92.2%;
        height: 85%;
    }
    .s-l-block img{
         100%;
        height: 100%;
    }
    /*要展示div的右侧样式*/
    .s-right{
         45%;
        height: 100%;
    }
    .s-r-title{
            margin-top: 2rem;
            margin-right: 10%;
            font-size: 2rem;
            color: #676769;
            font-weight: 500;
    }
    .s-r-span{
            margin-top: 1rem;
             100%;
    }
    .s-r-span span{
            color: #676769;
            font-size: 1.2rem;
            line-height: 2.5rem;
     }

    HTML代码:

     先看个图(图下面给代码----有点长,修改img路径就可以使用咯):

    <div class="ours-main">
        <div class="ours-swiper">
           <div class="swiper-container">
               <div class="swiper-wrapper">
                        <div class="swiper-slide">
                              <div class="s-left">
                                  <div class="s-l-block">
                                     <img src="img/foreign/center.png" />
                                   </div>
                              </div>
                              <div class="s-right">
                                  <div class="s-r-title">
                                      <span>外教abcd</span>
                                   </div>
                                   <div class="s-r-span">
                                      <span> Morbi sed mi luctus,temporarcu nec, hendrerit purus Proin non nibh id elit vulputateultrices. Integer finibus tinci dunt leo, eu vulputate nunc.Praesent elit massa, mollis eu magna acMorbi sed mi luctus, temporarcu nec, hendrerit purus Proin
                                      </span>
                                   </div>
                              </div>
                        </div>
                        <div class="swiper-slide">
                               <div class="s-left">
                                   <div class="s-l-block">
                                      <img src="img/foreign/center2.png" />
                                   </div>
                               </div>
                               <div class="s-right">
                                   <div class="s-r-title">
                                       <span>外教abcd</span>
                                   </div>
                                   <div class="s-r-span">
                                       <span> Morbi sed mi luctus,temporarcu nec, hendrerit purus Proin non nibh id elit vulputateultrices. Integer finibus tinci dunt leo, eu vulputate nunc.Praesent elit massa, mollis eu magna acMorbi sed mi luctus, temporarcu nec, hendrerit purus Proin
                                       </span>
                                   </div>
                              </div>
                        </div>
                        <div class="swiper-slide">
                                <div class="s-left">
                                    <div class="s-l-block">
                                       <img src="img/foreign/center3.png" />
                                    </div>
                               </div>
                                <div class="s-right">
                                    <div class="s-r-title">
                                        <span>外教abcd</span>
                                     </div>
                                     <div class="s-r-span">
                                         <span> Morbi sed mi luctus,temporarcu nec, hendrerit purus Proin non nibh id elit vulputateultrices. Integer finibus tinci dunt leo, eu vulputate nunc.Praesent elit massa, mollis eu magna acMorbi sed mi luctus, temporarcu nec, hendrerit purus Proin
                                     </span>
                                     </div>
                                </div>
                        </div>
                        <div class="swiper-slide">
                               <div class="s-left">
                                   <div class="s-l-block">
                                       <img src="img/foreign/center4.png" />
                                   </div>
                               </div>
                               <div class="s-right">
                                   <div class="s-r-title">
                                       <span>外教abcd</span>
                                   </div>
                                  <div class="s-r-span">
                                       <span> Morbi sed mi luctus,temporarcu nec, hendrerit purus Proin non nibh id elit vulputateultrices. Integer finibus tinci dunt leo, eu vulputate nunc.Praesent elit massa, mollis eu magna acMorbi sed mi luctus, temporarcu nec, hendrerit purus Proin
                                    </span>
                                  </div>
                            </div>
                        </div>
                        <div class="swiper-slide">
                               <div class="s-left">
                                   <div class="s-l-block">
                                       <img src="img/foreign/center5.png" />
                                   </div>
                               </div>
                               <div class="s-right">
                                   <div class="s-r-title">
                                       <span>外教abcd</span>
                                   </div>
                                   <div class="s-r-span">
                                       <span> Morbi sed mi luctus,temporarcu nec, hendrerit purus Proin non nibh id elit vulputateultrices. Integer finibus tinci dunt leo, eu vulputate nunc.Praesent elit massa, mollis eu magna acMorbi sed mi luctus, temporarcu nec, hendrerit purus Proin
                                       </span>
                                   </div>
                                </div>
                         </div>
              </div>
                                <!-- Add Arrows -->
                                <div class="swiper-button-next swiper-button-black"></div>
                                <div class="swiper-button-prev swiper-button-black"></div>
                            </div>
                        </div>
                    </div>

    js代码:

          <!--引入jquery.js-->
            <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
            <!--引入wow的js-->
            <script type="text/javascript" src="css/WOW-master/dist/wow.min.js"></script>
    <script>
    var swiper = new Swiper('.swiper-container', {
                    slidesPerView: 1.5, //设置slider容器能够同时显示的slides数量(carousel模式)。
                    spaceBetween: -180, //在slide之间设置距离(单位px)。
                    centeredSlides: true, //设置活动块居中
                    loop: true,
                    pagination: {
                        el: '.swiper-pagination',
                        clickable: true,
                    },
                    navigation: {
                        nextEl: '.swiper-button-next',
                        prevEl: '.swiper-button-prev',
                    },
                    autoplay: {
                        stopOnLastSlide: true,
                        delay: 5000
                    },
                });
                $('.swiper-container').mouseenter(function() {
                    $('.swiper-button-next').css('display', 'block')
                    $('.swiper-button-prev').css('display', 'block')
    
                }).mouseleave(function() {
                    $('.swiper-button-next').css('display', 'none')
                    $('.swiper-button-prev').css('display', 'none')
                })
    </script>
  • 相关阅读:
    关于installshield安装界面上installshield字样的删除问题
    复制加网站信息的javascript代码及对应的javascript阻止命令
    How to:Installshield判断操作系统是否为64位,并且为操作注册表进行设置
    Installshield在安装结束时刷新系统
    C# WinForm控件、自定义控件整理(大全)
    微软学生中心
    WPF嵌入式资源使用方法
    Application Block
    WPF绑定方式
    .Net3.5图表控件
  • 原文地址:https://www.cnblogs.com/a973692898/p/13364563.html
Copyright © 2020-2023  润新知