How add spaces between Slick carousel item

后端 未结 13 2628
野性不改
野性不改 2020-12-04 19:41

I want to add space between two slick carousel items, but not want the space with padding, because it\'s reducing my element size(and I don\'t want that).

13条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 19:59

    For example: Add this data-attr to your primary slick div: data-space="7"

                        $('[data-space]').each(function () {
                            var $this = $(this),
                                $space = $this.attr('data-space');
    
                            $('.slick-slide').css({
                                marginLeft: $space + 'px',
                                marginRight: $space + 'px'
                            });
    
                            $('.slick-list').css({
                                marginLeft: -$space + 'px',
                                marginRight: -$space/2 + 'px'
                            })
                        });
    

提交回复
热议问题