我想将光滑滑块的点放在prev和next按钮之间。 光滑提供设置,让您定位点/按钮。但他们会互相表现出来。
这是我的代码:
$('.slider').slick({
arrows: true,
prevArrow: '<button type="button" class="slick-prev"> <- </button>',
nextArrow: '<button type="button" class="slick-next"> -> </button>',
appendArrows:$('.slider-controls'),
dots: true,
appendDots:$('.slider-controls'),
});
它生成如下控件:
<div class="slider-controls d-flex align-items-center justify-content-center">
<button type="button" class="slick-prev slick-arrow" style=""> <- </button>
<button type="button" class="slick-next slick-arrow" style=""> -> </button>
<ul class="slick-dots" style="" role="tablist">
<li class="slick-active" role="presentation"><button type="button" role="tab" id="slick-slide-control00" aria-controls="slick-slide00" aria-label="1 of 3" tabindex="0" aria-selected="true">1</button></li>
<li role="presentation" class=""><button type="button" role="tab" id="slick-slide-control01" aria-controls="slick-slide01" aria-label="2 of 3" tabindex="-1">2</button></li>
<li role="presentation" class=""><button type="button" role="tab" id="slick-slide-control02" aria-controls="slick-slide02" aria-label="3 of 3" tabindex="-1">3</button></li>
</ul>
</div>
但我想要/需要这样:
<div class="slider-controls d-flex align-items-center justify-content-center">
<button type="button" class="slick-prev slick-arrow" style=""> <- </button>
<ul class="slick-dots" style="" role="tablist">
<li class="slick-active" role="presentation"><button type="button" role="tab" id="slick-slide-control00" aria-controls="slick-slide00" aria-label="1 of 3" tabindex="0" aria-selected="true">1</button></li>
<li role="presentation" class=""><button type="button" role="tab" id="slick-slide-control01" aria-controls="slick-slide01" aria-label="2 of 3" tabindex="-1">2</button></li>
<li role="presentation" class=""><button type="button" role="tab" id="slick-slide-control02" aria-controls="slick-slide02" aria-label="3 of 3" tabindex="-1">3</button></li>
</ul>
<button type="button" class="slick-next slick-arrow" style=""> -> </button>
</div>
我知道我可以用CSS定位按钮,但有几个原因,我需要像这样的HTML。
有什么办法吗?
答案 0 :(得分:1)
我找到了解决方案。 您可以添加以下代码以使用特定按钮作为lin
nextArrow: $('#next')
然后添加ID为
的自定义按钮<button type="button" class="slick-next" id="next"> <- </button>
完整代码:
$('.slider').slick({
arrows: true,
prevArrow: $('#prev'),
nextArrow: $('#next'),
dots: true,
});
<button type="button" class="slick-prev" id="prev"> -> </button>
<div class="slider">
<div>your content</div>
<div>your content</div>
<div>your content</div>
</div>
<button type="button" class="slick-next" id="next"> -> </button>