How to center the images in the Owl Carousel

后端 未结 5 1266
隐瞒了意图╮
隐瞒了意图╮ 2021-02-04 00:10

My Owl Carousel contains pictures of different width and height. How do I align them in the middle - both horizontally and vertically?

5条回答
  •  臣服心动
    2021-02-04 00:19

    With owl carousel version 2.1.1 and CSS3 Flexbox, just add the style:

    .owl-carousel .owl-stage {
      display: flex;
      align-items: center;
    }
    

    See the snippet:

    $( document ).ready( function() {
      $( '.owl-carousel' ).owlCarousel({
         autoplay: true,
         margin: 2,
         loop: true,
         responsive: {
            0: {
               items:1
            },
            200: {
               items:3
            },
            500: {
               items:4
            }
         }
      });
    });
    .owl-carousel .owl-stage {
      display: flex;
      align-items: center;
    }
    
    .owl-carousel .caption {
      text-align: center;
    }
    
    
    
    
    
    
    

提交回复
热议问题