TypechoJoeTheme

Dcr163的博客

统计

CSS3中设置动画播放方向

2017-03-23
/
0 评论
/
917 阅读
/
正在检测是否收录...
03/23

animation-direction属性主要用来设置动画播放方向,其语法规则如下:

animation-direction:normal | alternate [, normal | alternate]*

其主要有两个值:normalalternate

1、normal是默认值,如果设置为normal时,动画的每次循环都是向前播放;

2、另一个值是alternate,他的作用是,动画播放在第偶数次向前播放,第奇数次向反方向播放。

例如:通过animation-direction属性,将move动画播放动画方向设置为alternate,代码为:

animation-direction:alternate;

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8">
<title>变形与动画</title>
<link href="style.css" rel="stylesheet" type="text/css">
<style>
    @keyframes move {
      0%{
        transform: translateY(90px);
      }
      15%{
        transform: translate(90px,90px);
      }
      30%{
        transform: translate(180px,90px);
      }
      45%{
        transform: translate(90px,90px);
      }
      60%{
        transform: translate(90px,0);
      }
      75%{
        transform: translate(90px,90px);
      }
      90%{
        transform: translate(90px,180px);
      }
      100%{
        transform: translate(90px,90px);
      }
    }
    
    div {
      width: 200px;
      height: 200px;
      border: 1px solid red;
      margin: 20px auto;
    }
    span {
      display: inline-block;
      width: 20px;
      height: 20px;
      background: orange;
      transform: translateY(90px);
      animation-name: move;
      animation-duration: 10s;
      animation-timing-function: ease-in;
      animation-delay: .2s;
      animation-iteration-count:infinite;
      animation-direction:alternate;
    }
</style>
</head> 
<body>

<div><span></span></div>
</body>
</html>

注意:Chrome或Safari浏览器,需要加入-webkit-前缀!


朗读
赞(0)
版权属于:

Dcr163的博客

本文链接:

https://www.dcr163.cn/152.html(转载时请注明本文出处及文章链接)

评论 (0)

人生倒计时

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月

最新回复

  1. https://www.triptipedia.com/user/phmapaladnet
    2025-05-08
  2. https://Sites.google.com/view/vavada-online-casino
    2025-04-12
  3. https://x.com/jeetbuzzcom
    2025-04-07
  4. prozone.cc alternative
    2025-03-19
  5. urgent delivery
    2025-03-16

标签云