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 ...
随机推荐
- MAC平台下mysql7.5的安装
1.下载mysql(DMG格式64位的版本) http://dev.mysql.com/downloads/mysql/ 2.安装mysql 待下载*.dmg文件后双击,运行该安装文件 3.无限下一步 ...
- Unity中的CG编写Shader系列(Blend)
1.不透明度 当我们要将两个半透的纹理贴图到一个材质球上的时候就遇到混合的问题,由于前面的知识我们已经知道了片段着色器以及后面的环节的主要工作是输出颜色与深度到帧缓存中,所以两个纹理在每个像素上的颜色 ...
- jquery之选项卡效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- jQuery简单实现图片预加载
我们在做网站的时候经常会遇到这样的问题:一个页面有大量的图片导致页面加载速度缓慢,经常会出现一个白页用户体验很不好.那么如何解决这个问题呢?下面我来介绍一种在实际应用中经常会使用到的js预加载的方法. ...
- libusb 开发者指南-牛胜超(转)
源:libusb 开发者指南 libusb Developers Guidelibusb 开发者指南 原作者:Johannes Erdfelt翻译者:牛胜超 Table of Contents目录 P ...
- Java 汉子转拼音
1. 引入: pinyin4j-1.1.0 包; http://pan.baidu.com/s/1eQ8a874 2. 转换; private static String ChineseToPiny ...
- 程序员需要有多懒 ?- cocos2d-x 数学函数、常用宏粗整理 - by Glede
最近我们的cocos2d-x游戏项目已经进入了正式开发的阶段了,几个dev都辛苦码代码.cocos2d-x还是一套比较方便的api的,什么action啊.director啊.ccpoint啊都蛮便捷的 ...
- jmeter+ant+jenkins+mac 构建后自动发送邮件
1.安装Email Extension Plugin插件 2.进入系统管理-系统设置,按如下进行设置: ------------------------------------------------ ...
- zend framework 1.10项目配置与经典hello world
准备工作 前置条件:PHP>=5.14,Apache开启mod_rewrite支持,开启php的pdo扩展. Zend Framework 要求 PHP版本不低于5.1.4,但强烈建议使用 5. ...
- 如何解决Ajax跨域问题-1
如何解决Ajax跨域问题 最近在做AJAX调用C的问题,出现跨域问题,学习总结如下: 在做ajax读取数据的时候,经常会遇到ajax需要跨域的问题,但由于浏览器安全方面的限制,XMLHttpReque ...