我当时正在使用flex-Slider制作滑块。我有一个同步到一个我们做猫头鹰旋转木马两个flexsliders的想法。当flex-caption使用图像制作动画时,我必须使用两个flexslider,因为我希望flex-caption动画与图像动画不同。我已经把它们和这个同步了
Answer
但现在我被困在两点:
1) 我也要同步箭头。正如您在我的代码中看到的,我已经将flex-direction导航分组。现在我想在点击一个按钮时更改两张幻灯片,但这不起作用,因为上面有分层。
2) 我希望自定义目标按钮是活动的,取决于活动幻灯片。例如,我在第三张幻灯片上,我希望第三个目标锚定标记处于活动状态,比如颜色的改变等等。
希望我能把我的问题解释清楚。如果您需要任何进一步的信息,请在下面评论。
这是你的名字
Codepen
链接。后面是代码。
jQuery(document).ready(function($) {
$('#main-slider').flexslider({
animation: "slide",
slideToStart: 0,
start: function(slider) {
$('a.slide_thumb').click(function() {
$('.flexslider').show();
var slideTo = $(this).attr("rel") //Grab rel value from link;
var slideToInt = parseInt(slideTo) //Make sure that this value is an integer;
if (slider.currentSlide != slideToInt) {
slider.flexAnimate(slideToInt) //move the slider to the correct slide (Unless the slider is also already showing the slide we want);
}
});
}
});
$('#secondary-slider').flexslider({
animation: "slide",
slideToStart: 0,
start: function(slider) {
$('a.slide_thumb').click(function() {
$('.flexslider').show();
var slideTo = $(this).attr("rel") //Grab rel value from link;
var slideToInt = parseInt(slideTo) //Make sure that this value is an integer;
if (slider.currentSlide != slideToInt) {
slider.flexAnimate(slideToInt) //move the slider to the correct slide (Unless the slider is also already showing the slide we want);
}
});
}
});
});
.slider-wrap {
position: relative;
width: 700px;
margin: 0 auto
}
#secondary-slider {
position: absolute;
top: 0;
right: 0;
width: 50%;
}
.flex-direction-nav .flex-prev,
.flexslider:hover .flex-direction-nav .flex-prev,
.flexslider:hover .flex-direction-nav .flex-next,
.flex-direction-nav .flex-next {
top: unset;
left: unset;
right: unset;
bottom: unset;
}
.flexslider:hover .flex-direction-nav .flex-prev:hover,
.flexslider:hover .flex-direction-nav .flex-prev:hover {
opacity: 1;
}
#main-slider .flex-direction-nav .flex-prev,
#secondary-slider .flex-direction-nav .flex-prev {
position: absolute;
top: 20px !important;
right: 0 !important;
opacity: 1;
}
#main-slider .flex-direction-nav .flex-next,
#secondary-slider .flex-direction-nav .flex-next {
position: absolute;
top: 120px !important;
right: 0;
opacity: 1;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/flexslider/2.7.1/jquery.flexslider.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/flexslider/2.7.1/flexslider.css" rel="stylesheet" />
<div class="slider-wrap">
<div id="main-slider" class="flexslider">
<ul class="slides">
<li>
<img src="https://via.placeholder.com/350x150" />
</li>
<li>
<img src="https://via.placeholder.com/350x150" />
</li>
<li>
<img src="https://via.placeholder.com/350x150" />
</li>
<li>
<img src="https://via.placeholder.com/350x150" />
</li>
</ul>
</div>
<div id="secondary-slider" class="flexslider">
<ul class="slides">
<li>
<p>Text 1</p>
</li>
<li>
<p>Text 2</p>
</li>
<li>
<p>Text 3</p>
</li>
<li>
<p>Text 4</p>
</li>
</ul>
</div>
<a rel="0" class="slide_thumb" href="#">slide link 1</a>
<a rel="1" class="slide_thumb" href="#">slide link 2</a>
<a rel="2" class="slide_thumb" href="#">slide link 3</a>
<a rel="3" class="slide_thumb" href="#">slide link 3</a>