【问题标题】:How to add zoom effect to bootstrap carousel如何为引导轮播添加缩放效果
【发布时间】:2019-03-14 08:16:21
【问题描述】:

我正在尝试向引导轮播添加缩放效果,但我似乎无法触发它:(

我相信我可能必须将语法添加到核心 _carousel.scss 文件中(或者可能不会?)。因此,考虑到这一点,我尝试添加到常规 CSS 文件和 _carousel.scss 文件中,但没有任何乐趣。

可以请任何其他编码人员提供帮助吗?

.carousel-item {
  height: 100vh;
}

.carousel-image-1 {
  background: url("../img/image1.jpg");
  background-size: cover;
}

.carousel-image-2 {
  background: url("../img/image2.jpg");
  background-size: cover;
}

.carousel-image-3 {
  background: url("../img/image3.jpg");
  background-size: cover;
}

@-webkit-keyframes zoom {
 from {
  -webkit-transform: scale(1, 1);
 }
 to {
  -webkit-transform: scale(1.5, 1.5);
 }
}

@keyframes zoom {
 from {
  transform: scale(1, 1);
 }
 to {
  transform: scale(1.5, 1.5);
 }
}

.carousel-inner .carousel-item {
  -webkit-animation: zoom 5s;
  animation: zoom 5s;
}

<section id="showcase">
<div id="myCarousel" class="carousel slide carousel-fade" data-ride="carousel">
  <div class="carousel-inner">
    <div class="carousel-item carousel-image-1 active"></div>
    <div class="carousel-item carousel-image-2"></div>
    <div class="carousel-item carousel-image-3"></div>
  </div>
</div>

【问题讨论】:

  • 你想什么时候触发?
  • 希望它在每张幻灯片上触发,以便所有幻灯片都应用缩放动画
  • 设法找到不同的解决方案,以不同的方式应用关键帧,但您的方法也是一个很好的解决方案!

标签: jquery html css sass bootstrap-4


【解决方案1】:

我用这个代码没问题

.carousel-inner .carousel-item > img {
  -webkit-animation: thing 20s;
  -o-animation: thing 20s;
  animation: thing 20s; 
}
@keyframes thing {
  from {
     transform: scale(1, 1);
  }
  to {
    transform: scale(1.5, 1.5);
  }
}

【讨论】:

    猜你喜欢
    • 2016-10-27
    • 2021-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多