HTML 中animation的应用

 <!DOCTYPE html>
<html>
  <head>
    <title>animation动画</title>
    <meta charset="utf-8" />
    <style type="text/css">
      html,body{
        background-color:#000000;
        width:600px;
        height:600px;
        overflow:hidden;
      }
      #clock{
        position:relative;
        
        width:300px;
        height:300px;
        
        background-repeat:no-repeat;
        background-size:cover;
       background-image:url("res/lianxi/fun/pic/1.png");
       animation: ripple 2s linear infinite;
        /*补全css样式和animation动画*/
      }
 
      @keyframes ripple{
        /*补全animation动画效果*/
        0%{
           width:300px;
             height:300px;
        }
        50%{
             width:600px;
             height:600px;
        }
      }
      
    </style>
  </head>
  <body>
      <div id="clock">
     
    </div>
  </body>
 
</html>

HTML,`animation`属性是CSS动画的一种方式,它可以让元素在指定的时间内从一种样式过渡到另一种样式。该属性通常与`@keyframes`规则一起使用,`@keyframes`规则指定了动画的关键帧,即元素在动画过程应该出现的样式。 `animation`属性有以下几个可用值: - `animation-name`: 指定要应用的`@keyframes`规则的名称。 - `animation-duration`: 指定动画的持续时间,以秒或毫秒为单位。 - `animation-timing-function`: 指定动画的时间函数,即元素在动画过程的加速度曲线。 - `animation-delay`: 指定动画开始之前的延迟时间,以秒或毫秒为单位。 - `animation-iteration-count`: 指定动画应该重复多少次,或是否应该无限重复。 - `animation-direction`: 指定动画应该向前播放、向后播放、交替播放还是反向播放。 - `animation-fill-mode`: 指定动画在播放前和播放后如何应用样式。 - `animation-play-state`: 指定动画是否正在运行或已暂停。 以下是一个示例,演示如何使用`animation`属性: ```html <style> .box { width: 100px; height: 100px; background-color: red; animation-name: move; animation-duration: 2s; animation-timing-function: ease-in-out; animation-delay: 1s; animation-iteration-count: infinite; animation-direction: alternate; animation-fill-mode: forwards; animation-play-state: running; } @keyframes move { 0% { transform: translateX(0); } 50% { transform: translateX(100px); } 100% { transform: translateX(0); } } </style> <div class="box"></div> ``` 此示例将创建一个具有无限次交替播放的动画,该动画会使一个红色正方形元素在X轴上来回移动。动画将在1秒后开始,持续2秒,采用ease-in-out时间函数,并在动画结束时保留最终位置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值