作者热门文章
- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
在 Stackoverflow 上有几个关于 Carousel 淡入淡出过渡的问题,但似乎都不适用于默认的 4.0.0 实现:
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="..." alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="..." alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="..." alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
自 Alpha.6 版本以来,bootstrap 是否改变了 carousel-item
-s 的转换方式?在 4.0.0 中如何实现淡入淡出过渡而不是滑动?
最佳答案
Bootstrap 5 Carousel Fade(2021 年更新)
Bootstrap 5 includes a "fade" effect只需将 carousel-fade
类添加到 Carousel 即可使用。默认情况下,过渡持续时间为 0.6 秒。要增加持续时间并使幻灯片之间的淡入淡出速度变慢,请覆盖 CSS 上的过渡时间...
/* change transition duration to control the speed of fade effect */
.carousel-item {
transition: transform 2.6s ease-in-out;
}
.carousel-fade .active.carousel-item-start,
.carousel-fade .active.carousel-item-end {
transition: opacity 0s 2.6s;
}
Bootstrap 5 Carousel Fade Slower
Bootstrap 4.0 Carousel Fade(原答案)
.carousel-fade .carousel-item {
opacity: 0;
transition-duration: .6s;
transition-property: opacity;
}
.carousel-fade .carousel-item.active,
.carousel-fade .carousel-item-next.carousel-item-left,
.carousel-fade .carousel-item-prev.carousel-item-right {
opacity: 1;
}
.carousel-fade .active.carousel-item-left,
.carousel-fade .active.carousel-item-right {
opacity: 0;
}
.carousel-fade .carousel-item-next,
.carousel-fade .carousel-item-prev,
.carousel-fade .carousel-item.active,
.carousel-fade .active.carousel-item-left,
.carousel-fade .active.carousel-item-prev {
transform: translateX(0);
transform: translate3d(0, 0, 0);
}
淡入淡出效果在 4.0 Beta 期间从轮播中移除,并且在 4.0.0 中也不可用。这pull request表示淡入淡出效果将在 4.1 或 4.2 中返回。同时,上述 CSS 将适用于 4.0.0
关于css - 更改 Bootstrap Carousel 淡入淡出过渡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48665392/
我是一名优秀的程序员,十分优秀!