简体   繁体   English

如何在引导轮播中使用100%宽度的图像来防止动画期间的高度变化

[英]How to prevent height change during animation using 100% width images in bootstrap carousel

Bootstrap 3 carousel should use fixed-height images during animation. Bootstrap 3旋转木马在动画过程中应使用固定高度的图像。 Carousel is created using code from bootstrap tutorial Carousel是使用引导教程中的代码创建的

 <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
    <div class="carousel-inner" role="listbox">
            <div class="item active">
                <a href="124">
                    <img class="carousel-img" src="124" />
                </a>
            </div>
            <div class="item ">
                <a href="123">
                    <img class="carousel-img" src="123" />

                </a>
            </div>
    </div>
</div>

Image widths are set to carousel width using answer from 使用以下命令的答案将图像宽度设置为轮播宽度

How to center image in carousel 如何在轮播中将图片居中

.carousel-img {
    width: 100%;
    height: auto;
}

I screen resolution is big and zoom level is small, image height decreases on animation. 我的屏幕分辨率较大,缩放级别较小,动画时图像高度会降低。 How to use fixed height so that content does not jump ? 如何使用固定高度以使内容不跳动?

Just add this CSS, 只需添加此CSS,

.carousel-inner > .item{
   width: 100%;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM