Fork me on GitHub

swiper左右选项卡滑动

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Swiper demo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="swiper.min.css">
  <script src="swiper.min.js"></script>
  <style>
    html, body {
      position: relative;
      height: 100%;
    }
    body {
      background: #eee;
      font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
      font-size: 14px;
      color:#000;
      margin: 0;
      padding: 0;
    }
    .swiper-container2 {
      width: 100%;
      height: 100%;
    }
    .swiper-container {
      width: 100%;
      height: 100%;
    }
    .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;
    }
    .miaomiao{
        background-color: #fff;
        position: absolute;
        top:50px;
        height:200px;
        width:100%;
    }
    .miaomiao2{
        position: absolute;
        top:300px;
        height:200px;
        width:100%;
        background-color: #fff;
    }
    .swiper-button-next{
        outline: none;
    }
    .swiper-button-prev{
        outline: none
    }
  </style>
</head>
<body>
<div class="miaomiao">
    <div class="swiper-container2">
        <div class="swiper-wrapper">
              <div class="swiper-slide">
                    <div style="width:80%;height:100%;background: #ddd;position: absolute;">
                        <div>name1</div>
                    </div>
              </div>
              <div class="swiper-slide">
                   <div style="width:80%;height:100%;background: #ddd;position: absolute;">
                       <div>name2</div>
                   </div>
              </div>
        </div>
        <div class="swiper-button-next"></div>
        <div class="swiper-button-prev"></div>
    </div>
    <div class="miaomiao2" style="">
    <div class="swiper-container">
        <div class="swiper-wrapper">
              <div class="swiper-slide">
                    <div style="width:80%;height:100%;background: #ddd;position: absolute;">
                        <div>name3</div>
                    </div>
              </div>
              <div class="swiper-slide">
                   <div style="width:80%;height:100%;background: #ddd;position: absolute;">
                       <div>name4</div>
                   </div>
              </div>
        </div>
        <div class="swiper-button-next swiper-button-next1"></div>
        <div class="swiper-button-prev swiper-button-prev1"></div>
    </div>
</div>
</div>

<script>
new Swiper('.swiper-container2', {
  navigation: {
    nextEl: '.swiper-button-next',
    prevEl: '.swiper-button-prev',
  },
});
new Swiper('.swiper-container', {
  navigation: {
    nextEl: '.swiper-button-next1',
    prevEl: '.swiper-button-prev1',
  },
});
</script>
</body>
</html>

 

posted @ 2018-05-10 13:35  森海轮回  阅读(2415)  评论(0编辑  收藏  举报