不能影响轮播宽度

Can't affect carousel width

努力改变轮播宽度。

旋转木马的图片是竖向的,所以宽度太大了。一直在玩 width (%, px, vh) 并且似乎没有任何影响旋转木马的宽度。它始终显示相同。

  .owl-carousel.major-caousel .slider-item {
    width: 50%;
  }

  .owl-carousel.major-caousel .slider-item img {
    margin-bottom: 0;
    position: relative;
    object-fit:cover;
    top: 0;
    max-height: 70vh;
  }

html

<section class="section slider-section">
    <div class="row">
        <div class="col-md-12">
            <div class="home-slider major-caousel owl-carousel mb-5" data-aos="fade-up" data-aos-delay="200">
                <div class="slider-item">
                    <img src="/../img/cover_up/<?php echo $product->name . $i . ".jpg"; ?>" alt="Image placeholder" class="img-fluid">
                </div>
            </div>
        </div>
    </div>
</section>

设置 width: 100% 只会使图像恢复其原始大小(因此缩放)。还玩过max-widthwidth

想法?

编辑:添加 html.

如果我没记错的话,您正在使用 owl 轮播。

CSS代码

.owl-carousel .owl-stage-outer {
    width: 50%;
    margin: 0 auto;
}

同样在轮播对象中将显示的项目数更改为 1

var owl = $('.owl-carousel');
        owl.owlCarousel({
            loop: true,
            dots: false,
            autoplay: true,
            autoplayTimeout: 4000,
            autoplayHoverPause: true,
            responsive: {
                0: {
                    items: 1, // make sure this number is 1 to display one item in the slide
                    nav: true
                }
            }
        });