I'm using Slick.js carousel on a Wordpress site I'm developing. When I resize the browser window, the carousels won't fit it, causing horizontal scrollbars to show up. If I don't initiate Slick, the images resize accordingly, as you would expect in a fluid layout.
Slick injects some inline styles dynamically, and one of them is the width. You can see the width accross all child divs of the carousel: Slick inline styles
Slick's normal behavior is to update those widths as you resize the window, but for some reason it won't happen on this site.
Here is the link to the website: http://smart.trippple.com.br/
The home page has two carousels, located at these positions:
- main #slider-home .container .slider-session
- main #seguradoras .container #seguradoras-carrousel .slider-session
This is how I'm initiating the script:
$('#slider-home .slider-session').slick({
autoplay: true,
autoplaySpeed: 5000,
arrows: false,
fade: true,
slidesToScroll: 1,
slidesToShow: 1,
speed: 1000
});
$('#seguradoras-carrousel .slider-session').slick({
autoplay: true,
autoplaySpeed: 2000,
arrows: false,
centerMode: true,
mobileFirst: true,
pauseOnHover: false,
slidesToShow: 4
});
And here is everything I tried so far:
- Deactivated all scripts except for jQuery and Slick to make sure there isn't a conflict taking place;
- Tested different versions of jQuery;
- Tried including jQuery Migrate;
- Tried to load jQuery + Slick in the site's header;
- Tried to remove the carousels from the container;
- Tried to set a width and max-width to the carousel div on my stylesheet;
Tried to use Slick's resize method:
$(window).resize(function() { $('#slider-home .slider-session').slick('resize'); });
Researching everywhere and even opening an issue on the plugin's Github page. The plugin author replied that the script definitely resizes and the problem is in my environment, and he is right. I created a static HTML page to test, and the carousel was 100% responsive. There is something on this website which is preventing the script's normal behavior.
By the way, you won't see Slick's stylesheets linked because I embedded them into the site's main stylesheet.
Any help is really appreciated! I'm trying to solve this for about two weeks, at least, and I don't know what else to try. Any ideas are welcome. Thank you!