【问题标题】:Trigger css animation only when it tis visible into the viewport仅当它在视口中可见时才触发 css 动画
【发布时间】:2021-05-01 15:55:11
【问题描述】:

所以,我的页面上有一个文本动画。问题是动画只有在整个页面加载时才会触发!所以,我的页面中间有这个动画,几乎不可能看到这是一个动画文本!请需要解决方案! HTML 代码:

<div class="animated-title" id="anime" >
  <div class="text-top">
    <div>
      <span>So! What Are You </span>
      <span>Waiting For?</span>
    </div>
  </div>
  <div class="text-bottom">
    <div>Just click And LEARN!</div>
  </div>
</div>

CSS 代码:

.animated-title {
  color: #222;
  font-family: Roboto, Arial, sans-serif;
  height: 90vmin;
  left: 30%;
  position: absolute;
  top: 156%;
  transform: translate(-50%, -50%);
  width: 90vmin;
}
.animated-title > div {
  height: 50%;
  overflow: hidden;
  position: absolute;
  width: 100%;
}
.animated-title > div div {
  font-size: 9vmin;
  padding: 3vmin 0;
  position: absolute;
}
.animated-title > div div span {
  display: block;
}
.animated-title > div.text-top {
  border-bottom: 1.4vmin solid rgb(13, 231, 13);
  top: 0;
  border-radius: 20px;
}
.animated-title > div.text-top div {
  animation: showTopText 1s;
  animation-delay: 7s;
  animation-fill-mode: forwards;
  bottom: 0;
  transform: translate(0, 100%);
}
.animated-title > div.text-top div span:first-child {
  color: #767676;
}
.animated-title > div.text-bottom {
  bottom: 0;
}
.animated-title > div.text-bottom div {
  animation: showBottomText 1s;
  animation-delay: 5s;
  animation-fill-mode: forwards;
  top: 0;
  transform: translate(0, -100%);
}


关键帧:

  0% { transform: translate3d(0, 100%, 0); }
  40%, 60% { transform: translate3d(0, 50%, 0); }
  100% { transform: translate3d(0, 0, 0); }
}
@keyframes showBottomText {
  0% { transform: translate3d(0, -100%, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

【问题讨论】:

    标签: html css animation


    【解决方案1】:

    我想我明白你的问题是什么。 只要在代码中包含库没有问题,就可以这样做: https://www.youtube.com/watch?v=XtjO-OWFyfU

    顺便说一句,网上有很多教程。你只需要搜索。

    【讨论】:

    • 好吧,如果你给我一些使用“amp”的例子对我来说会更容易。我无法获得视频的例子!
    猜你喜欢
    • 1970-01-01
    • 2023-03-10
    • 2014-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-26
    • 1970-01-01
    相关资源
    最近更新 更多