CSS3 animation小动画
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Examples</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
<style>
*{
padding: 0;
margin: 0;
}
.btn{
width: 200px;
text-align: center;
}
.test{
width: 90px;
height: 60px;
background: url(img/test.png) no-repeat;
margin: 60px;
/*-webkit-animation: run 350ms steps(1) infinite 0s;*/
-webkit-animation: run 350ms steps(5) infinite 0s;
}
/*@-webkit-keyframes run{
0%{
background-position: 0;
}
20%{
background-position: -90px 0;
}
40%{
background-position: -180px 0;
}
60%{
background-position: -270px 0;
}
80%{
background-position: -360px 0;
}
100%{
background-position: -450px 0;
}
}*/
@-webkit-keyframes run{
100%{
background-position: -450px 0;
}
}
</style>
<script>
var speed =350;
var flag = true;
function fast(){
var obj = document.getElementById('flash');
speed-=10;
// console.log(obj.style.webkitAnimation) //为何获取不到??????
obj.style.webkitAnimation = " run "+speed+"ms steps(5) infinite 0s"
}
function slow(){
var obj = document.getElementById('flash');
speed+=10;
// console.log(obj.style.webkitAnimation) //为何获取不到??????
obj.style.webkitAnimation = " run "+speed+"ms steps(5) infinite 0s"
}
function play(){
var obj = document.getElementById('flash');
flag = !flag;
obj.style.webkitAnimationPlayState = flag ? "running" : "paused";
}
</script>
</head>
<body>
<div id='flash' class="test"></div>
<div class="btn"><button onclick="fast()">跑快点</button> <button onclick="slow()">跑慢点</button> <button onclick="play()">暂停/开始</button></div>
</body>
</html>
效果图


CSS3 animation小动画的更多相关文章
- CSS3 animation(动画) 属性
一.animation 1.CSS3 animation(动画) 属性 语法: animation: name duration timing-function delay iteration-cou ...
- 深入理解CSS3 Animation 帧动画
CSS3我在5年之前就有用了,包括公司项目都一直在很前沿的技术. 最近在写慕课网的七夕主题,用了大量的CSS3动画,但是真的沉淀下来仔细的去深入CSS3动画的各个属性发现还是很深的,这里就写下关于帧动 ...
- CSS3 Animation 帧动画 steps()
@keyframes fn{ 0%{} 100%{} } CSS3的Animation有八个属性 animation-name :动画名 fn animation-duration:时间 1s ani ...
- 深入理解CSS3 Animation 帧动画 ( steps )
作者:Aaron的博客 网址:http://www.cnblogs.com/aaronjs/p/4642015.html --------------------------------------- ...
- 深入理解CSS3 Animation 帧动画(转)
CSS3我在5年之前就有用了,包括公司项目都一直在很前沿的技术. 最近在写慕课网的七夕主题,用了大量的CSS3动画,但是真的沉淀下来仔细的去深入CSS3动画的各个属性发现还是很深的,这里就写下关于帧动 ...
- css3的帧动画
概述 前几天刚好看到一个用了CSS3帧动画的页面,对它非常感兴趣,就研究了一下,记录在下面,供以后开发时参考,相信对其他人也有用. PS:以后别人问我用过什么CSS3属性的时候,我也可以不用说常见的a ...
- css3 animation动画技巧
一,css3 animation动画前言 随着现在浏览器对css3的兼容性越来越好,使用css3动画来制作动画的例子也越来越广泛,也随着而来带来了许多的问题值得我们能思考.css3动画如何让物体运动更 ...
- css3 animation实现逐帧动画
css3里面的animation属性非常强大,但是自己用的比较少,最近有次面试就刚好被问到了,趁现在有时间就对animation做一个小总结.同时实现一个逐帧动画的demo作为练习 animation ...
- css3 animation动画特效插件的巧用
这一个是css3 animation动画特效在线演示的网站 https://daneden.github.io/animate.css/ 下载 animate.css文件,文件的代码很多,不过要明白 ...
随机推荐
- a letter and a number
描述we define f(A) = 1, f(a) = -1, f(B) = 2, f(b) = -2, ... f(Z) = 26, f(z) = -26;Give you a letter x ...
- Oracle基础(六) 数据类型
一.Oracle中的数据类型 Oracle中提供了丰富的数据类型,用来存储数据,主要包括: 1.字符类型:主要用来存储字符串类型的数据. 数据类型 长度 说明 CHAR(n BYTE/CHAR) 默认 ...
- python pdb调试
在交互环境中通常使用pdb.run来调试: import pdb def pdb_test(arg): for i in range(arg): print(i) return arg pdb.run ...
- cxGrid使用汇总2
17. 怎样设计多表头的cxGrid? 解决:cxGrid可以解决如下的表头: --------------------------------- | 说明1 | 说明2 | ------------ ...
- self.view添加UIView时添加动画
CATransition *animation = [CATransition animation]; animation.delegate = self; animation.duration = ...
- missing required architecture x86_64 in file 不支持64位
( slices) 解决方法:
- JavaScript中的getBoundingClientRect()方法
这个方法返回一个矩形对象,包含四个属性:left.top.right和bottom.分别表示元素各边与页面上边和左边的距离. getBoundClientRect()方法返回的对象中和CSS中所定义不 ...
- POJ1064
#include <iostream> #include <iomanip> #include <cmath> using namespace std; int N ...
- Part 45 to 47 Talking about Enums in C#
Part 45 C# Tutorial Why Enums Enums are strongly typed constants. If a program uses set of integ ...
- log4Net 简单配置实用
<configSections> <section name="log4net" type="log4net.Config.Log4NetConfigu ...