Using the Slick Carousel with a background image in a Isotope (masonry) grid - height of slides becomes 1px

后端 未结 1 923
名媛妹妹
名媛妹妹 2021-02-11 05:31

I\'m using isotope to generate a dynamic grid of blocks. Some blocks can have a carousel inside of them. I\'m using the Slick Carousel (http://kenwheeler.github.io/slick/) to do

相关标签:
1条回答
  • 2021-02-11 05:58

    The problem is that your slides are set to height: 100%, but when slick.js is initialized, it inserts new DOM elements and breaks your heirarchy, so that the parent of each slide has no height.

    With a little extra javascript, you can force the parents of the individual slides (which is inserted by slick.js) to match the height of the isotope container.

    The DOM elements inserted as parents to the slides are: div.slick-list and div.slick-track

    Use javascript to set the height of .slick-list to match the height of the container, and use css to set .slick-track to 100%. Then the height of the individual slide will propogate correctly once again.

    See here for a working example: http://jsfiddle.net/9dja3omp/5/

    Also, slick.js must be init'd after isotope. Here's another example without the 3 second delay: http://jsfiddle.net/9dja3omp/6/

    0 讨论(0)
提交回复
热议问题