简体   繁体   English

光滑的滑块人工居中

[英]Slick slider artificially center

I am using JQuery Slick Slider http://kenwheeler.github.io/slick/ which works perfectly. 我正在使用JQuery Slick Slider http://kenwheeler.github.io/slick/ ,它非常有效。

I also have a separate script running which checks the page url and if a link in the slick slider has the same url then a class of current is added to that particular link. 我还运行了一个单独的脚本,该脚本检查页面url,并且如果滑动滑块中的链接具有相同的url,则将current类添加到该特定链接。

This script is as follows: 该脚本如下:

jQuery(document).ready(function($) {
    var url = window.location.href;
    $('#slick a').filter(function() {
        return this.href == url;
    }).addClass('current');
});

This again works perfectly. 这再次完美。

I am looking to extend this though so that the link with the class of current is centered in the Slick Slider. 我希望对此进行扩展,以使与current类别的链接位于Slick Slider中。 If anyone knows how to do this then I would be very grateful if you could point me in the right direction. 如果有人知道该怎么做,那么如果您能指出正确的方向,我将不胜感激。

Thank you 谢谢

You can use 'centerMode' and 'slickGoTo' settings of the slick slider. 您可以使用滑动滑块的“ centerMode”和“ slickGoTo”设置。 centerMode will keep your current slide in the center. centerMode将使当前幻灯片保持在中心。 With your condition get the count of the element which is current and then using slickGoTo(count) you can center that element. 根据您的条件获取当前元素的计数,然后使用slickGoTo(count)可以将该元素居中。 For more details see the settings menu http://kenwheeler.github.io/slick/ . 有关更多详细信息,请参见设置菜单http://kenwheeler.github.io/slick/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM