TypechoJoeTheme

Dcr163的博客

统计

CSS3中设置动画的播放状态

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

animation-play-state属性主要用来控制元素动画的播放状态

参数:

其主要有两个值:runningpaused

其中running是其默认值,主要作用就是类似于音乐播放器一样,可以通过paused将正在播放的动画停下来,也可以通过running将暂停的动画重新播放,这里的重新播放不一定是从元素动画的开始播放,而是从暂停的那个位置开始播放。另外如果暂停了动画的播放,元素的样式将回到最原始设置状态。

例如,页面加载时,动画不播放。代码如下:

animation-play-state:paused;
<!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;
      animation-play-state:paused;
    }
    div:hover span {
      animation-play-state:running;
    }
</style>
</head> 
<body>

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


朗读
赞(0)
版权属于:

Dcr163的博客

本文链接:

https://www.dcr163.cn/153.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

标签云