N
N
Norum2021-03-18 07:53:19
Owl Carousel
Norum, 2021-03-18 07:53:19

Why are the images in the owl-carousel block displayed incorrectly?

How can I make sure that the images in the block in the gallery are displayed one at a time and do not stretch? For some reason they all show up for me. Tried to set owl-item=100%, but it doesn't help.
PS you need to click on the 'Manicure' block

code https://jsfiddle.net/eptdhbvr/

site tempeswo.beget.tech

6052dc9e604fe936397295.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladik Bubin, 2021-03-18
@ikoit

items
Type: Number
1
The number of items you want to see on the screen.

$('.owl-carousel').owlCarousel({
    loop:true,
    margin:10,
    responsiveClass:true,
    responsive:{
        0:{
            items:1
        },
        600:{
            items:1
        },
        1000:{
            items:1
        }
    }
})

F
fallus, 2021-03-18
@fallus

1. Replace it;

$('.col.img.owl-carousel').owlCarousel({
  autoplayHoverPause: true,
  nav: true,
  navText: true,
  dots: true,
  autoplay: true,
  center: true,
  loop: true,
  margin: 10,
  responsiveClass: true,
  responsive: {
    0: {
      items: 1,
      margin: 20
    },
    370: {
      items: 2,
      margin: 20
    },
    800: {
      items: 3
    },
    1000: {
      items: 4
    }
  }
})

On this:
// Поместили слайдер в переменную, чтобы потом использовать
var myCarousel = $('.col.img.owl-carousel').owlCarousel({
  autoplayHoverPause: true,
  nav: true,
  navText: true,
  dots: true,
  autoplay: true,
  center: true,
  loop: true,
  margin: 10,
  responsiveClass: true,
  items: 1,
  responsive: {
    0: {
      items: 1,
      margin: 20
    },
    370: {
      items: 2,
      margin: 20
    },
    800: {
      items: 3
    },
    1000: {
      items: 1 // Изменили значение на 1
    }
  }
})

2. Remove attributes from the markup data-fancybox
Because of them, FancyBox is instantaneously initialized. Without settings.
3. Replace this:
$().fancybox({
  selector: '.gallery .owl-item:not(.cloned) a'
})

On this:
$('.services .item').fancybox({
  // После того как попап открылся
  afterShow: function(instance, current) {
  // Обновляем слайдер
    myCarousel.trigger('refresh.owl.carousel')
  }
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question