通过CSS3属性值的变化实现动画效果+触发这些动画产生交互
css3过渡
transition
兼容性:IE10+
transition: none | all | property
默认为none
all 表示所有属性过渡
property 指定属性值,如color opacity
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body{
margin:0 auto;
background:#abcdef;
}
.box{
width:700px;
height:700px;
margin:0 auto;
background:url(source/pic.png) center no-repeat;
cursor: pointer;
-webkit-transform:rotate(0deg);
-moz-transform:rotate(0deg);
-ms-transform:rotate(0deg);
-o-transform:rotate(0deg);
transform:rotate(0deg);
-webkit-transition-property:transform;
-moz-transition-property:transform;
-ms-transition-property:transform;
-o-transition-property:transform;
transition-property:transform;
}
.box:hover{
-webkit-transform:rotate(180deg);
-moz-transform:rotate(180deg);
-ms-transform:rotate(180deg);
-o-transform:rotate(180deg);
transform:rotate(180deg);
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>

transition-duration 动画持续时间
transition-timing-function: linear | ease | ease-in | ease-out | ease-in-out
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body{
margin:0 auto;
background:#abcdef;
}
.box{
width:700px;
height:700px;
margin:0 auto;
background:url(source/pic.png) center no-repeat;
cursor: pointer;
-webkit-transform:rotate(0deg);
-moz-transform:rotate(0deg);
-ms-transform:rotate(0deg);
-o-transform:rotate(0deg);
transform:rotate(0deg);
-webkit-transition-property:transform;
-moz-transition-property:transform;
-ms-transition-property:transform;
-o-transition-property:transform;
transition-property:transform;
-webkit-transition-duration:2s;
-moz-transition-duration:2s;
-ms-transition-duration:2s;
-o-transition-duration:2s;
transition-duration:2s;
-webkit-transition-timing-function:linear;/*线性*/
-moz-transition-timing-function:linear;
-ms-transition-timing-function:linear;
-o-transition-timing-function:linear;
transition-timing-function:linear;
-webkit-transition-timing-function:ease;/*平滑*/
-moz-transition-timing-function:ease;
-ms-transition-timing-function:ease;
-o-transition-timing-function:ease;
transition-timing-function:ease;
-webkit-transition-timing-function:ease-in;/*缓入*/
-moz-transition-timing-function:ease-in;
-ms-transition-timing-function:ease-in;
-o-transition-timing-function:ease-in;
transition-timing-function:ease-in;
-webkit-transition-timing-function:ease-out;/*缓出*/
-moz-transition-timing-function:ease-out;
-ms-transition-timing-function:ease-out;
-o-transition-timing-function:ease-out;
transition-timing-function:ease-out;
-webkit-transition-timing-function:ease-in-out;/*缓入缓出*/
-moz-transition-timing-function:ease-in-out;
-ms-transition-timing-function:ease-in-out;
-o-transition-timing-function:ease-in-out;
transition-timing-function:ease-in-out;
}
.box:hover{
-webkit-transform:rotate(180deg);
-moz-transform:rotate(180deg);
-ms-transform:rotate(180deg);
-o-transform:rotate(180deg);
transform:rotate(180deg);
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>

transition-delay 过渡延迟
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body{
margin:0 auto;
background:#abcdef;
}
.box{
width:700px;
height:700px;
margin:0 auto;
background:url(source/pic.png) center no-repeat;
cursor: pointer;
-webkit-transform:rotate(0deg);
-moz-transform:rotate(0deg);
-ms-transform:rotate(0deg);
-o-transform:rotate(0deg);
transform:rotate(0deg);
-webkit-transition-property:transform;
-moz-transition-property:transform;
-ms-transition-property:transform;
-o-transition-property:transform;
transition-property:transform;
-webkit-transition-duration:2s;
-moz-transition-duration:2s;
-ms-transition-duration:2s;
-o-transition-duration:2s;
transition-duration:2s;
-webkit-transition-timing-function:ease-in-out;/*缓入缓出*/
-moz-transition-timing-function:ease-in-out;
-ms-transition-timing-function:ease-in-out;
-o-transition-timing-function:ease-in-out;
transition-timing-function:ease-in-out;
-webkit-transition-delay:1s;
-moz-transition-delay:1s;
-ms-transition-delay:1s;
-o-transition-delay:1s;
transition-delay:1s;
}
.box:hover{
-webkit-transform:rotate(180deg);
-moz-transform:rotate(180deg);
-ms-transform:rotate(180deg);
-o-transform:rotate(180deg);
transform:rotate(180deg);
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>

transtion简写
transition: property duration timing-function delay
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body{
margin:0 auto;
background:#abcdef;
}
.box{
width:700px;
height:700px;
margin:0 auto;
background:url(source/pic.png) center no-repeat;
cursor: pointer;
-webkit-transform:rotate(0deg);
-moz-transform:rotate(0deg);
-ms-transform:rotate(0deg);
-o-transform:rotate(0deg);
transform:rotate(0deg);
-webkit-transition:transform 2s ease-in-out 1s;
-moz-transition:transform 2s ease-in-out 1s;
-ms-transition:transform 2s ease-in-out 1s;
-o-transition:transform 2s ease-in-out 1s;
transition:transform 2s ease-in-out 1s;
}
.box:hover{
-webkit-transform:rotate(180deg);
-moz-transform:rotate(180deg);
-ms-transform:rotate(180deg);
-o-transform:rotate(180deg);
transform:rotate(180deg);
-webkit-transition:transform 2s ease-in-out 1s;
-moz-transition:transform 2s ease-in-out 1s;
-ms-transition:transform 2s ease-in-out 1s;
-o-transition:transform 2s ease-in-out 1s;
transition:transform 2s ease-in-out 1s;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
通过CSS3属性值的变化实现动画效果+触发这些动画产生交互的更多相关文章
- js 获取和设置css3 属性值的实现方法
众多周知 CSS3 增加了很多属性,在读写的时候就没有原先那么方便了. 如:<div style="left:100px"></div> 只考虑行间样式的话 ...
- javascript动画效果之缓冲动画(修改版)
在编写多块同时触发运动的时候,发现一个BUG, timer = setInterval(show, 30);本来show是一个自定义函数,当设为timer = setInterval(show(one ...
- Android 动画效果 及 自定义动画
1. View动画-透明动画效果2. View动画-旋转动画效果3. View动画-移动动画效果4. View动画-缩放动画效果5. View动画-动画效果混合6. View动画-动画效果侦听7. 自 ...
- Java 给PPT添加动画效果(预设动画/自定义动画)
PPT幻灯片中对形状可设置动画效果,常见的动画效果为内置的固定类型,即动画效果和路径是预先设定好的固定模板,但在设计动画效果时,用户也可以按照自己的喜好自定义动画动作路径.下面,通过Java后端程序代 ...
- 012 Android 动画效果(补间动画) +去掉App默认自带的标题+更改应用的图标
1.介绍 补间动画开发者只需指定动画开始,以及动画结束"关键帧", 而动画变化的"中间帧"则由系统计算并补齐! 2.去掉App的标题 (1)将AndroidMa ...
- jQuery演示10种不同的切换图片列表动画效果以及tab动画演示 2
很常用的一款特效纯CSS完成tab实现5种不同切换对应内容效果 实例预览 下载地址 实例代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ...
- 根据Expander的IsExpanded属性值的变化动态设计Control的size
简要说明: 当Expander 的IsExpanded属性为“True” 时给控件设个尺寸(此处为高度),当为“False”时给控件设另外一个值. 知识点:数据绑定.Style和Trigger < ...
- CSS3属性值之box-shadow
语法: box-shadow:inset x-offset y-offset blur-radius spread-radius color 也就是: 对象选择器 {box-shadow:投影 ...
- Vue中如何监控某个属性值的变化?
比如现在需要监控data中, obj.a 的变化.Vue中监控对象属性的变化你可以这样: deep属性表示深层遍历,但是这么写会监控obj的所有属性变化,并不是我们想要的效果,所以做点修改: 还有一种 ...
随机推荐
- Spring5.x源码分析 | 从踩坑到放弃之环境搭建
Spring5.x源码分析--从踩坑到放弃之环境搭建 前言 自从Spring发行4.x后,很久没去好好看过Spring源码了,加上最近半年工作都是偏管理和参与设计为主,在技术细节上或多或少有点疏忽,最 ...
- <背包>solution_CF366C_Dima and Salad
Dima and Salad Dima, Inna and Seryozha have gathered in a room. That's right, someone's got to go. T ...
- 搭建DevOps模式的项目
在后端的开发领域,各类开发框架都已经很多,在开发项目时可以根据不同的需要和需求选择合适的开发框架.然而在需要开发一个完善的工程化项目时,仅仅一个后端开发框架是不够的,还面临着在对开发项目的快速迭代中进 ...
- 计算机网络基础:TCP和UDP
UDP(用户数据报协议) 应用场景:一个数据包就能完成数据通信:不需要建立会话和流量控制:多播.广播:是一种不可靠传输.(例如QQ聊天,屏幕广播) UDP协议特点: UDP是无连接的,即发送数据之前不 ...
- idea个人配置记录
idea.properties # Use ${idea.home.path} macro to specify location relative to IDE installation home. ...
- 三、 TCP(传输控制协议)
它建立在网际层协议(IP)提供的数据包传输技术之上,.TCP使应用程序可使用连续的数据进行通信.除非由于网络故障导致连接中断或冻结,TCP都能保证数据流完好地传输.而不会发生丢包 ,重包或是乱序的问题 ...
- java字符编码-Unicode编码问题刨根究底
博客搬家: java字符编码问题 前段时间在读<java核心技术卷一>,遇到一些名词:码点.代码单元等,其实字面意思不难理解,解释如下 码点(code point):Unicode编码表中 ...
- 机器学习(ML)九之GRU、LSTM、深度神经网络、双向循环神经网络
门控循环单元(GRU) 循环神经网络中的梯度计算方法.当时间步数较大或者时间步较小时,循环神经网络的梯度较容易出现衰减或爆炸.虽然裁剪梯度可以应对梯度爆炸,但无法解决梯度衰减的问题.通常由于这个原因, ...
- 研究微信红包分配算法之Golang版
今天来看一下红包的分配,参考几年前流传的微信红包分配算法,今天用Golang实现一版,并测试验证结果. 微信红包的随机算法是怎样实现的?https://www.zhihu.com/question/2 ...
- 详解c++中对二维数组下标[][]的重载
首先定义一个矩阵类,我用一个二维数组存储矩阵中的数据,矩阵详细定义如下 class Matrix { public: Matrix(int rows, int cols) { _rows = rows ...