5

使用危险的刷卡器,请参阅 Slide1 lets go to google。如果 Slide1 位于原始位置(框中的第一个左侧),则指向 google 的链接将始终有效。但是,如果我们滑动(或鼠标左右拖放)并且 Slide1 位于位置 2 或 3,则单击将不起作用。

http://jsfiddle.net/C8ytu/

<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Demo</title>
  <link rel="stylesheet" href="http://www.idangero.us/sliders/swiper/css/idangerous.swiper.css">
  <style>
/* Demo Styles */
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.5;
}
.swiper-container {
  width: 660px;
  height: 250px;
  color: #fff;
  text-align: center;
}
.red-slide {
  background: #ca4040;
}
.blue-slide {
  background: #4390ee;
}
.orange-slide {
  background: #ff8604;
}
.green-slide {
  background: #49a430;
}
.pink-slide {
  background: #973e76;
}
.swiper-slide .title {
  font-style: italic;
  font-size: 42px;
  margin-top: 80px;
  margin-bottom: 0;
  line-height: 45px;
}
.pagination {
  position: absolute;
  z-index: 20;
  left: 10px;
  bottom: 10px;
}
.swiper-pagination-switch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 8px;
  background: #222;
  margin-right: 5px;
  opacity: 0.8;
  border: 1px solid #fff;
  cursor: pointer;
}
.swiper-visible-switch {
  background: #aaa;
}
.swiper-active-switch {
  background: #fff;
}
  </style>
</head>
<body>
  <div class="swiper-container">
    <div class="swiper-wrapper">
      <div class="swiper-slide red-slide">
        <div class="title"><a href="http://www.google.com" target="_blank">lets go to google</a></div>
      </div>
      <div class="swiper-slide blue-slide">
        <div class="title">Slide 2</div>
      </div>
      <div class="swiper-slide orange-slide">
        <div class="title">Slide 3</div>
      </div>
      <div class="swiper-slide green-slide">
        <div class="title">Slide 4</div>
      </div>
      <div class="swiper-slide pink-slide">
        <div class="title">Slide 5</div>
      </div>
      <div class="swiper-slide red-slide">
        <div class="title">Slide 6</div>
      </div>
      <div class="swiper-slide blue-slide">
        <div class="title">Slide 7</div>
      </div>
      <div class="swiper-slide orange-slide">
        <div class="title">Slide 8</div>
      </div>
    </div>
    <div class="pagination"></div>
  </div>
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://www.idangero.us/sliders/swiper/js/idangerous.swiper.js"></script>

  <script>
  var mySwiper = new Swiper('.swiper-container',{
    pagination: '.pagination',
    paginationClickable: true,
    slidesPerView: 3,
    loop: true
  })
  </script>
</body>
</html>
4

2 回答 2

6

您必须添加loopAdditionalSlides:3代码并解决您的问题。

在这里查看JSFiddle

JS:

var mySwiper = new Swiper('.swiper-container',{
    pagination: '.pagination',
    loopAdditionalSlides:3,    //<-- This one
    paginationClickable: true,
    slidesPerView: 3,
    loop: true
});

loopAdditionalSlides:“创建循环后将克隆的幻灯片的添加数量”

文档:Swiper 用法和 API

于 2013-09-09T16:11:29.130 回答
4

所以似乎在向右滑动标签没有被点击。我只是在这方面帮助你。看一下滑动前的屏幕截图和滑动后的屏幕截图

滑动前滑动

向右滑动后滑动

我更改了一些代码并对其进行了窃听。似乎您的 js 文件正在添加一种对父 div 的点击

<div class="swiper-slide orange-slide swiper-slide-visible swiper-slide-active" style="width: 165px; height: 250px;">
    <div class="title">Slide 8<br><a href="http://www.google.com" target="_blank">lets go to google</a></div>
  </div>

它在父 div 上添加额外的类

swiper-slide-visible swiper-slide-active

但是向左滑动时相同的是不会在任何地方添加任何类。它保留默认类

swiper-slide orange-slide

检查 JS ...我只能指导你 :) 如果你愿意,那就去解决问题,但如果你可以编辑 js 进行点击,那么请做。告诉我这是否不能解决您的问题:)

于 2013-09-13T12:15:34.370 回答