javascript - html 从初始位置向上移动文本动画

标签 javascript css animation text

我正在尝试了解如何让文本从幻灯片中的初始位置向上 float 。怎么样OnGuardian在他们的网站上做。我已经尝试过 CSS animated 和 w3 animate 但问题是它不会从设置位置向上移动它只是从底部移动到原始位置。我愿意使用 CSS、Javascript 和 HTML。

这是我的代码

    <li style="background-image: linear-gradient(to bottom, rgba(0,0,0,0.2) 0%,rgba(0,0,0,0.2) 100%), url(Images/homepage1.jpg)">
       <img  class ="slider-image" src="Images/tenniscentrallogo1.png">
        <!-- <div class="slider-logo "><span></span></div> -->
        <div class="slider-content ">
          <div class="slider-container ">
            <div class="slider-center ">
              <div class=" w3-animate-bottom slider-header">
                <h2> Financial freedom & fun at your fingertips </h2>
              </div>
              <p class = " w3-animate-bottom slidertext"> Take an  quantum leap into the future. Start a lucrative tennis business today with our dynamic team at your service</p>
                <a class="btn play-video-btn" href="#" data-toggle="modal" data-target="#videoModal" preload="auto">Watch the video</a>
          </div>
        </div>
      </div>
    </li>

我想为 slider-header 类和 slider-text 类设置动画。我的问题更多的是不知道如何找到想要的效果。

最佳答案

首先,确保您的文本在样式声明中包含 position:absolute;,然后尝试使用 bottom 属性的 CSS3 动画。

    @-webkit-keyframes moveUp {
          from { bottom : /* initial */ ; }
          to { bottom : /* some extent of move up like initial - 30px */ ; }
    }


    #text {
      -webkit-animation-name : moveUp ;
      -webkit-animation-duration: 1s;
      -webkit-animation-fill-mode: forwards ; /* to avoid the element going back to the initial position */
    }

关于javascript - html 从初始位置向上移动文本动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43789617/

相关文章:

javascript - 为什么alert/console.log 使用 Jquery 拖放运行不同的数量

javascript - Facebook 评论插件如何工作?

html - 显示屏上出现水平滚动条 : table element

css - 当 CSS 被禁用时,如何隐藏 div?

html - CSS 列百分比无法按预期工作

javascript - AngularJS 未在 Flask 应用程序中运行

javascript - 我正在使用 Bootstrap 模型。但是当我在 js 端调用一个函数时它关闭了,我希望它打开

jquery - 当页面滚动到特定百分比时,如何向元素添加Class?

javascript - 从左/右/上/下动画时淡入 div

python - 更新 matplotlib 动画中的 x 轴标签