css3 3d变换和动画——回顾
1.transform-style 属性指定嵌套原始是怎样在三维空间中呈现。
语法:transform-style: flat | preserve-3d
flat 表示所有子元素在2D平面呈现。
preserve-3d 表示所在元素在3D空间中呈现。
2.perspective 定义3D元素距视图的距离,以像素计,当为元素定义perspective 属性时,其子元素获得透视效果,而不是元素本身
语法:perspective: number | none;
number 元素距离视图的距离,以像素计。
none 默认值,与0 相同,不设置透明。
3.perspective-origin 属性定义3D元素所基于的X轴和Y轴,该属性允许您改变3D 元素的底部位置,定义的这个属性,它是一个元素的子元素,透视图,而不是元素本身。
语法:perspective-origin: x-axis y-axis
x-axis 定义该视图在x轴上的位置。
y-axis 定义该视图在y轴上的位置。
示例:
<style>
.box{width:60px;height:60px;padding:40px;border:2px solid #000;margin:30px auto; -webkit-transform-style:preserve-3d;-webkit-
perspective:100px;}
.div{width:60px;height:60px;background:red; transition:1s;}
.box:hover .div{-webkit-transform:rotateX(180deg);}
</style>
<div class="box">
<div class="div">111</div>
</div>
结果:如图

示例:
<style>
.box{width:60px;height:60px;padding:40px;border:2px solid #000;margin:30px auto; -webkit-
transform-style:preserve-3d;-webkit-perspective:100px;}
.div{width:60px;height:60px;background:red; transition:1s;}
.box:hover .div{-webkit-transform:rotateY(180deg);}
</style>
<div class="box">
<div class="div">111</div>
</div>
结果:如图

示例:
<style>
.box{width:60px;height:60px;padding:40px;border:2px solid #000;margin:30px auto; -webkit-
transform-style:preserve-3d;-webkit-perspective:100px;}
.div{width:60px;height:60px;background:red; transition:1s;}
.box:hover .div{-webkit-transform:rotateZ(180deg);}
</style>
<div class="box">
<div class="div">111</div>
</div>
结果:如图

示例:(正方形)
<style>
.wrap{width:60px;height:60px;padding:20px; border:2px solid #000; margin:100px auto;
-webkit-perspective:200px; -webkit-transform:scale(2);-webkit-perspective-origin:center center;}
.box{width:60px;height:60px;background:red; position:relative; -webkit-transform-style:preserve-3d; transition:2s;
-webkit-transform-origin:center center -50px;}
.box div{width:60px;height:60px; position:absolute; color:#fff;font-size:50px; text-align:center;line-height:60px;}
.box div:nth-of-type(1){left:0;top:-60px;background:#9C0; -webkit-transform-origin:bottom; -webkit-transform:rotateX(90deg);}
.box div:nth-of-type(2){left:-60px;top:0px;background:#CF3; -webkit-transform-origin:right; -webkit-transform:rotateY(-90deg);}
.box div:nth-of-type(3){left:0px;top:0px;background:#CCF;}
.box div:nth-of-type(4){left:60px;top:0;background:#0C9;-webkit-transform-origin:left;-webkit-transform:rotateY(90deg);}
.box div:nth-of-type(5){left:0px;top:60px;background:#69C;-webkit-transform-origin:top;-webkit-transform:rotateX(-90deg);}
.box div:nth-of-type(6){left:0;top:0;background:#F0C;-webkit-transform:translateZ(-60px) rotateX(180deg);}
.wrap:hover .box{ -webkit-transform:rotateX(180deg);}
</style>
<div class="wrap">
<div class="box">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>
</div>
结果:如图

4.animation
Keyframes 具有其自己的语法规则 ,他的命名是由”@keyframes“ 开头,后面紧接着这个动画的名称 加上一堆花括号。
对于一个"@keyframes"中的样式规则是由多个百分比构成的,如“0%”到"100%"之间
@keyframes IDENT {
from {
Properties:Properties value;
}
Percentage {
Properties:Properties value;
}
to {
Properties:Properties value;
}
}
或者全部写成百分比的形式:
@keyframes IDENT {
0% {
Properties:Properties value;
}
Percentage {
Properties:Properties value;
}
100% {
Properties:Properties value;
}
}
其中IDENT是一个动画名称,你可以随便取,当然语义化一点更好,
@-webkit-keyframes 'wobble' {
0% {
margin-left: 100px;
background: green;
}
40% {
margin-left: 150px;
background: orange;
}
60% {
margin-left: 75px;
background: blue;
}
100% {
margin-left: 100px;
background: red;
}
}
元素调用animation属性
如:
.demo1 {
width: 50px;
height: 50px;
margin-left: 100px;
background: blue;
-webkit-animation-name:'wobble';/*动画属性名,也就是我们前面keyframes定义的动画名*/
-webkit-animation-duration: 10s;/*动画持续时间*/
-webkit-animation-timing-function: ease-in-out; /*动画频率,和transition-timing-function是一样的*/
-webkit-animation-delay: 2s;/*动画延迟时间*/
-webkit-animation-iteration-count: 10;/*定义循环资料,infinite为无限次*/
-webkit-animation-direction: alternate;/*定义动画方式*/
}
属性:
1.animation-name:
语法:animation-name: none | IDENT[,none | IDENT]*;
animation-name:是用来定义一个动画的名称,其主要有两个值:IDENT是由Keyframes创建的动画名,
换句话说此处的IDENT要和Keyframes中的IDENT一致,
如果不一致,将不能实现任何动画效果;none为默认值,当值为none时,将没有任何动画效果。另外我们这
个属性跟前面所讲的transition一样,我们可以同时附
几个animation给一个元素,我们只需要用逗号“,”隔开。
2.animation-duratiuon
语法:animation-duration: <time>[,<time>]*
animation-duration是用来指定元素播放动画所持续的时间长,取值:<time>为数值,单位为s (秒.)其默认值为“0”。
这个属性跟transition中的transition-duration使用方法是一样的。
3.animation-timing-function:
animation-timing-function:是指元素根据时间的推进来改变属性值的变换速率,说得简单点就是动画的播放方式。
他和transition中的transition-timing-function一样,具有以下六种变换方式:ease;ease-in;ease-in-out;linear;cubic-bezier。
具体的使用方法大家可以点这里,查看其中transition-timing-function的使用方法。
4.animation-delay
语法:animation-delay: <time>[,<time>]*
animation-delay:是用来指定元素动画开始延迟时间。取值为<time>为数值,单位为s(秒),其默认值也是0。
这个属性和transition-delayy使用方法是一样的。
5.animation-iteration-count
animation-iteration-count:infinite | <number> [, infinite | <number>]*
animation-iteration-count是用来指定元素播放动画的循环次数,其可以取值<number>为数字,其默认值为“1”;infinite为无限次数循环。
6.animation-direction
语法: animation-direction: normal | alternate [, normal | alternate]*
animation-direction是用来指定元素动画播放的方向,其只有两个值,默认值为normal,如果设置为normal时,
动画的每次循环都是向前播放;
另一个值是alternate,他的作用是,动画播放在第偶数次向前播放,第奇数次向反方向播放。
7.animation-play-state
语法:animation-play-state:running | paused [, running | paused]*
animation-play-state主要是用来控制元素动画的播放状态。其主要有两个值,running和paused其中running为默认值。
他们的作用就类似于我们的音乐播放器一样,可以通过paused将正在播放的动画停下了,也可以通过running将暂停的动画重新播放,
我们这里的重新播放不一定是从元素动画的开始播放,而是从你暂停的那个位置开始播放。
示例:
<style>
@-webkit-keyframes anim
{
0%{
width:100px;
}
100%
{
width:200px;
}
}
.box{width:100px;height:100px;background:red; -webkit-animation:2s anim;}
</style>
<div class="box"></div>
结果:如图

示例:
<style>
@-webkit-keyframes anim
{
0%{
width:100px;
}
100%
{
width:200px;
}
}
.box{width:100px;height:100px;background:red; -webkit-animation:2s anim infinite linear;}
</style>
<div class="box"></div>
结果:动画从头到尾的速度是相同的。
示例:
<style>
@-webkit-keyframes anim
{
0%{
width:100px;
}
100%
{
width:200px;
}
}
.box{width:100px;height:100px;background:red; -webkit-animation:2s anim ease-in infinite;}
</style>
<div class="box"></div>
结果:如图

示例:
<style>
@-webkit-keyframes move
{
0%{
left:0;
}
100%
{
left:-500px;
}
}
#wrap{ width:500px;height:100px;border:1px solid #000; position:relative;margin:100px auto; overflow:hidden;}
#list{ position:absolute;left:0;top:0;margin:0;padding:0; -webkit-animation:5s move infinite linear; width:200%;}
#list li{ list-style:none;width:98px;height:98px;border:1px solid #fff;background:#000; color:#fff; font:50px/98px Arial; text-align:center; float:left;}
#wrap:hover #list{ -webkit-animation-play-state:paused;}
</style>
<div id="wrap">
<ul id="list">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
结果:循环运动,鼠标悬浮停止。
5.animation-play-state 规定动画是正在运行还是暂停
语法:animation-play-state: paused | running
paused 动画已暂停
running 动画正在播放
demo下载https://github.com/ningmengxs/css3.git
css3 3d变换和动画——回顾的更多相关文章
- css3 3D变换和动画
3D变换和动画 建立3D空间,transform-style: preserve-3d perspective: 100px; 景深 perspective-origin:center center ...
- CSS3 3D变换
可以这么说,3D变换是基于三维坐标系的.以下是“盗用”的图 CSS3中的3D变换主要包括以下几个功能函数: 3D位移:包括translateZ()和translate3d(): 3D旋转:包括rota ...
- CSS3 3D变换实例 滚动的正方体
笔记: 2D变换 transform 位移 translateX() translateY() 简写:translate(X值,Y值) 正值向右,负值向左 旋转 rotate() rotat ...
- css3 3d效果及动画学习
css参考手册: http://www.phpstudy.net/css3/ http://www.css88.com/book/css/ 呈现3d效果:-webkit-transform-style ...
- jQuery/CSS3 3D焦点图动画
在线演示 本地下载
- CSS3 3D折叠展开动画菜单
在线演示 本地下载
- 【Web动画】CSS3 3D 行星运转 && 浏览器渲染原理
承接上一篇:[CSS3进阶]酷炫的3D旋转透视 . 最近入坑 Web 动画,所以把自己的学习过程记录一下分享给大家. CSS3 3D 行星运转 demo 页面请戳:Demo.(建议使用Chrome打开 ...
- 我用 CSS3 实现了一个超炫的 3D 加载动画
今天给大家带来一个非常炫酷的CSS3加载Loading动画,它的特别之处在于,整个Loading动画呈现出了3D的视觉效果.这个Loading加载动画由12个3D圆柱体围成一个椭圆形,同时这12个圆柱 ...
- CSS3之3D变换实例详解
CSS3的3D效果很赞,本文实现简单的两种3D翻转效果.首先看效果和源代码,文末是文绉绉的总结部分^_^ 以下CSS代码为了简洁没有添加前缀,请视情况自行添加(自动化时代推荐使用其他的一些方法,如gu ...
随机推荐
- 自动安装脚本-------------基于LVMP搭建Nagios 监控
Mysql初始化参数(mysql-5.6.31) /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local ...
- Android开发之回调函数
写在前面,最近对回掉函数有了更深刻的认识,现在记录如下.由于在家看不到底层代码,在公司不能访问外网,现在只能凭靠记忆写这篇博文了,写错的地方还希望大神们指出来 其实给组件设置监听就是最典型的回掉函数的 ...
- iOS开发之监听键盘高度的变化 分类: ios技术 2015-04-21 12:04 233人阅读 评论(0) 收藏
最近做的项目中,有一个类似微博中的评论转发功能,屏幕底端有一个输入框用textView来做,当textView成为第一响应者的时候它的Y值随着键盘高度的改变而改变,保证textView紧贴着键盘,但又 ...
- php传输大数据大文件时候php.ini相关设置
post_max_size which is directly related to the POST size---针对采用post上传的,大文件,此项为关键 upload_max_filesize ...
- 【转】 谈谈C++中的swap函数
1,最通用的模板交换函数模式:创建临时对象,调用对象的赋值操作符. template <class T> void swap ( T& a, T& b ) { T c(a) ...
- 安装ARM交叉编译器
1.开发平台 虚拟机:VMware 12 操作系统:Ubuntu 14.04 64bit 2.准备ARM交叉编译工具包 编译uboot和linux kernel都需要ARM交叉工具链支持,这里使用Li ...
- ios 自定义NSError
from:[object-c错误处理]http://www.androiddev.net/objective-c%E5%AD%A6%E4%B9%A0%E4%B9%8B%E9%94%99%E8%AF%A ...
- IOS开发-UI学习-使用代码创建button
使用代码创建button分5个步骤,分别是: 1.定义一个按钮,根据定义位置不同可定义为局部变量或者全局变量: 2.初始化按钮,一般使用一个矩形初始化: 3.设置按钮控件的其他属性,如背景图片,或者背 ...
- UVa 11495 - Bubbles and Buckets
题目大意:给一个有n个数的序列,通过交换相邻的逆序数使这个序列最终有序,求需要交换的次数. 本来可以用冒泡排序解决,但是n达到105,用冒泡排序会超时,用O(nlogn)的归并排序可以达到要求.< ...
- BZOJ2698染色
2698: 染色 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 223 Solved: 150[Submit][Status][Discuss] De ...