简体   繁体   中英

Angular Slick Slider Responsive Breakpoint - Each Slide Separates Into Smaller Components

I have a slick slider with Bulma CSS cards. It works until I reach a breakpoint and set my slidesToShow as a different number. The cards are composed of a header and a content body. When the breakpoint reaches, the card header and body are separate slides.

slideConfig = {
    'slidesToShow': 4,
    'slidesToScroll': 1,
    'arrows': true,
    'swipeToSlide': true,
    'infinite': false,
    'responsive': [
      {
        'breakpoint': 767,
        'slidesToShow': 3
      }
    ]
  };

HTML:

<ngx-slick class="carousel" #slickModal="slick-modal" [config]="slideConfig" responsive="breakpoints">
      <div ngxSlickItem *ngFor="let slide of slides" class="slide">
        <div class="card">
          <header class="card-header">
            <p class="card-header-title">
              Box {{slide}}
            </p>
          </header>
          <div class="card-content">
            <div class="content">
              <p>Content for slide {{slide}}</p>
              Lorem ipsum dolor sit amet, consectetur adipiscing elit.
            </div>
          </div>
        </div>
      </div>
</ngx-slick

enter image description here

try this

'responsive': [
  {
    'breakpoint': 767,
     'settings': {
      'slidesToShow': 3
            }
          }
        ]

You have missed the setting part. if you make it responsive you have to add setting and options iside of it. if you add multiple breakpoints try this,

responsive: [
    {
      breakpoint: 1024,
      settings: {
        slidesToShow: 3
      }
    },
    {
      breakpoint: 600,
      settings: {
        slidesToShow: 2
      }
    },
    {
      breakpoint: 480,
      settings: {
        slidesToShow: 1
      }
    }
  ]

I hope this will work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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