Bootstrap CSS背景-图像缩小

jaxagkaj  于 2023-06-20  发布在  Bootstrap
关注(0)|答案(1)|浏览(198)

我使用的是4张图像的引导旋转木马滑块,最后2张图像完全适合,前2张不适合,它们在顶部被切断,前两张图像是4000 x 3000,最后两张是4000 x 2000。有办法缩小背景图像吗?我使用background-size:封面和我的前两个图像被切断,有没有人有任何建议,我应该做什么?

.fill { width: 100%;  height: 100%; background-position: center; background-size: cover; }

<header id="myCarousel" class="carousel slide">
                <!-- Indicators -->
                <ol class="carousel-indicators">
                    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
                    <li data-target="#myCarousel" data-slide-to="1"></li>
                    <li data-target="#myCarousel" data-slide-to="2"></li>
                    <li data-target="#myCarousel" data-slide-to="3"></li>
                </ol>

                <!-- Wrapper for Slides -->
                <div class="carousel-inner">
                    <div class="item active">
                        <!-- Set the first background image using inline CSS below. -->
                        <div class="fill" style="background-image:url('/Images/banner-images/slider-1.jpg?v=4789372489');"></div>
                    </div>
                    <div class="item">
                        <!-- Set the second background image using inline CSS below. -->
                        <div class="fill" style="background-image:url('/Images/banner-images/slider-2.jpg?v=4789372489');"></div>
                    </div>
                    <div class="item">
                        <!-- Set the third background image using inline CSS below. -->
                        <div class="fill" style="background-image:url('/Images/banner-images/slider-3.jpg?v=4789372489');"></div>
                    </div>
                    <div class="item">
                        <!-- Set the third background image using inline CSS below. -->
                        <div class="fill" style="background-image:url('/Images/banner-images/slider-4.jpg?v=4789372489');"></div>
                    </div>
                </div>

                <!-- Controls -->
                <a class="left carousel-control" href="#myCarousel" data-slide="prev">
                    <span class="icon-prev"></span>
                </a>
                <a class="right carousel-control" href="#myCarousel" data-slide="next">
                    <span class="icon-next"></span>
                </a>

            </header>


.carousel {
    height: 600px;
}

@media (min-width: 768px) {

    .carousel {
        height: 75vh;
    }
}
tct7dpnv

tct7dpnv1#

试试纵横比。这可能有助于比例。

相关问题