Owlcarousel2: can change the position of prev button and next button

Created on 3 Nov 2017  路  5Comments  路  Source: OwlCarousel2/OwlCarousel2

image
now the prev button and next button below the carousel. can any setting change the position of buttons?

for example,
likes below image
image

Most helpful comment

You could do this using CSS,

.owl-prev,
.owl-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.owl-prev {
  left: -2rem;
}

.owl-next {
  right: -2rem;
}

You might have to adjust the -2rem as needed. If you are using dots, you might also need to make them absolutely positioned so it doesn't affect the height of the whole carousel and make the prev/next elements not be vertically centred.

All 5 comments

You could do this using CSS,

.owl-prev,
.owl-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.owl-prev {
  left: -2rem;
}

.owl-next {
  right: -2rem;
}

You might have to adjust the -2rem as needed. If you are using dots, you might also need to make them absolutely positioned so it doesn't affect the height of the whole carousel and make the prev/next elements not be vertically centred.

Another option is leaving nav: false, creating your desired buttons anywhere you like with html/css, and then setting them up to trigger the previous and next events on the carousel element, like so:

    var carouselEl = $('.owl-carousel');

    carouselEl.owlCarousel({
        items: 6
    });

    $(".my-next-button").click(function() {
        carouselEl.trigger('next.owl.carousel');
    });

    $(".my-previous-button").click(function() {
        carouselEl.trigger('prev.owl.carousel');
    });

Seems like this is one is solved.

Another option is leaving nav: false, creating your desired buttons anywhere you like with html/css, and then setting them up to trigger the previous and next events on the carousel element, like so:

    var carouselEl = $('.owl-carousel');

    carouselEl.owlCarousel({
        items: 6
    });

    $(".my-next-button").click(function() {
        carouselEl.trigger('next.owl.carousel');
    });

    $(".my-previous-button").click(function() {
        carouselEl.trigger('prev.owl.carousel');
    });

This works fine for a single carousel, but for multiple carousels, it moves all the carousels.

hi team ,
when i click on next button i skip some slide directly go another slide,
i want track my slide when i click next same on previous option but always go last slide not my flow of previous step of slider.

Was this page helpful?
0 / 5 - 0 ratings