CSS3 笔记四(Transforms)

CSS3 2D Transforms Methods

  • translate()
  • rotate()
  • scale()
  • skewX()
  • skewY()
  • matrix()

1> translate

  • The translate() method moves an element from its current position (according to the parameters given for the X-axis and the Y-axis).

2> rotate

  • The rotate() method rotates an element clockwise or counter-clockwise according to a given degree.

Example

1 div {
2     -ms-transform: rotate(20deg); /* IE 9 */
3     -webkit-transform: rotate(20deg); /* Safari */
4     transform: rotate(20deg);
5 } 

3> scale

  • The scale() method increases or decreases the size of an element (according to the parameters given for the width and height).

4> skewX(沿X轴形变)

  • The skewX() method skews an element along the X-axis by the given angle.

5> skewY(沿Y轴形变)

  • The skewY() method skews an element along the Y-axis by the given angle.

6> skew(沿X和Y轴形变)

  • The skew() method skews an element along the X and Y-axis by the given angles.

7> matrix

  • The matrix() method combines all the 2D transform methods into one.

Example

1 div {
2     -ms-transform: matrix(1, -0.3, 0, 1, 0, 0); /* IE 9 */
3     -webkit-transform: matrix(1, -0.3, 0, 1, 0, 0); /* Safari */
4     transform: matrix(1, -0.3, 0, 1, 0, 0);
5 } 

CSS3 3D Transforms

  • rotateX()
  • rotateY()
  • rotateZ()

1> rotateX

  • The rotateX() method rotates an element around its X-axis at a given degree.

2> rotateY

  • The rotateY() method rotates an element around its Y-axis at a given degree.

3> rotateZ

  • The rotateZ() method rotates an element around its Z-axis at a given degree:

Example

1 div {
2     -webkit-transform: rotateZ(90deg); /* Safari */
3     transform: rotateZ(90deg);
4 } 

CSS3 Transitions

  • Specify the CSS property you want to add an effect to.
  • Specify the duration of the effect.

Note: If the duration part is not specified, the transition will have no effect, because the default value is 0.

syntax

transition: property duration timing-function delay|initial|inherit;

Example

1 input[type=text] {
2     width: 100px;
3     -webkit-transition: ease-in-out, width .35s ease-in-out; /* Safari 3.1 to 6.0 */
4     transition: width .35s ease-in-out;
5 }
6
7 input[type=text]:focus {
8     width: 250px;
9 }

1> transition-property

  • Specify the name of the CSS property

syntax

transition-property: none|all|property|initial|inherit;

Example

1 div {
2     -webkit-transition-property: width, height; /* Safari */
3     transition-property: width, height;
4 }
5
6 div:hover {
7     width: 300px;
8     height: 300px;
9 }

2> transition-duration

  • Specifies how many seconds (s) or milliseconds (ms) a transition effect takes to complete.

syntax

transition-duration: time|initial|inherit;

Example

1 div {
2     -webkit-transition-duration: 5s; /* Safari */
3     transition-duration: 5s;
4 }

3> transition-delay

  • The transition-delay property specifies when the transition effect will start.
  • The transition-delay value is defined in seconds (s) or milliseconds (ms).

syntax

transition-delay: time|initial|inherit;

Example

1 div {
2     -webkit-transition-delay: 2s; /* Safari */
3     transition-delay: 2s;
4 }

4> transition-timing-function

  • The transition-timing-function property specifies the speed curve of the transition effect.
  • This property allows a transition effect to change speed over its duration.

syntax

transition-timing-function: ease|linear|ease-in|ease-out|ease-in-out|cubic-bezier()|initial|inherit;
Value Description
ease Default value. Specifies a transition effect with a slow start, then fast, then end slowly (equivalent to cubic-bezier(0.25,0.1,0.25,1))
linear Specifies a transition effect with the same speed from start to end (equivalent to cubic-bezier(0,0,1,1))
ease-in Specifies a transition effect with a slow start (equivalent to cubic-bezier(0.42,0,1,1))
ease-out Specifies a transition effect with a slow end (equivalent to cubic-bezier(0,0,0.58,1))
ease-in-out Specifies a transition effect with a slow start and end (equivalent to cubic-bezier(0.42,0,0.58,1))
cubic-bezier(n,n,n,n) Define your own values in the cubic-bezier function. Possible values are numeric values from 0 to 1
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Example

 1 /* For Safari 3.1 to 6.0 */
 2 #div1 {-webkit-transition-timing-function: linear;}
 3 #div2 {-webkit-transition-timing-function: ease;}
 4 #div3 {-webkit-transition-timing-function: ease-in;}
 5 #div4 {-webkit-transition-timing-function: ease-out;}
 6 #div5 {-webkit-transition-timing-function: ease-in-out;}
 7
 8 /* Standard syntax */
 9 #div1 {transition-timing-function: linear;}
10 #div2 {transition-timing-function: ease;}
11 #div3 {transition-timing-function: ease-in;}
12 #div4 {transition-timing-function: ease-out;}
13 #div5 {transition-timing-function: ease-in-out;}

CSS3 Animations

The @keyframes Rule

1> animation

syntax

animation: name duration timing-function delay iteration-count direction fill-mode play-state;

Example

1 div {
2     -webkit-animation: mymove 5s infinite; /* Chrome, Safari, Opera */
3     animation: mymove 5s infinite;
4 } 

2> animation-name

  • The animation-name property specifies a name for the @keyframes animation.

syntax

animation-name: keyframename|none|initial|inherit;

Example

 1 /* The animation code */
 2 @keyframes example {
 3     from {background-color: red;}
 4     to {background-color: yellow;}
 5 }
 6
 7 /* The element to apply the animation to */
 8 div {
 9     width: 100px;
10     height: 100px;
11     background-color: red;
12     animation-name: example;
13     animation-duration: 4s;
14 } 

3> animation-duration

4> animation-timing-function

5> animation-delay

6> animation-iteration-count

7> animation-direction

8> animation-fill-mode

9> animation-play-state

时间: 2024-11-25 09:37:19

CSS3 笔记四(Transforms)的相关文章

Caliburn.Micro学习笔记(四)----IHandle<T>实现多语言功能

Caliburn.Micro学习笔记(四)----IHandle<T>实现多语言功能 说一下IHandle<T>实现多语言功能 因为Caliburn.Micro是基于MvvM的UI与codebehind分离, binding可以是双向的所以我们想动态的实现多语言切换很是方便今天我做一个小demo给大家提供一个思路 先看一下效果 点击英文  变成英文状态点chinese就会变成中文                          源码的下载地址在文章的最下边 多语言用的是资源文件建

代码管理工具 --- git的学习笔记四《重新整理git(1)》

1.创建版本库 mkdir  创建目录 cd  地址,到该地址下 pwd 显示当前目录 1.创建目录 $ mkdir startGit $ cd startGit $ pwd 显示当前目录 或者cd到桌面,然后再创建目录 2.初始化版本库 $ git init 初始化仓库 提示信息:Initialized empty Git repository in /Users/xingzai/Desktop/startGit/.git/ 建立一个空的git仓库在/Users/xingzai/Desktop

Linux学习笔记四:Linux的文件搜索命令

1.文件搜索命令  which 语法:which [命令名称] 范例:$which ls  列出ls命令所在目录 [[email protected] ~]$ which ls alias ls='ls --color=auto' /bin/ls 另外一个命令:whereis [名称名称],也可以列出命令所在目录. [[email protected] ~]$ whereis ls ls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/ma

小猪的数据结构学习笔记(四)

小猪的数据结构学习笔记(四) 线性表之静态链表 --转载请注明出处:coder-pig 本章引言: 在二,三中中我们分别学习了顺序表中的线性表与单链表,线性表有点类似于 我们前面所学的数组,而单链表使用的最多的是指针,这里问个简单的问题, 如果是在以前没有指针的话,前辈先人们怎么实现单链表呢?大家思考下! 没有指针,那么用什么来代替呢?前辈先人们非常机智,想出了使用下标+游标的方式 来实现单链表的效果!也就是今天要讲的--静态链表! 当然你也可以直接跳过本章,因为有了单链表就没有必要用静态链表了

R实战读书笔记四

第三章 图形入门 本章概要 1 创建和保存图形 2 定义符号.线.颜色和坐标轴 3 文本标注 4 掌控图形维数 5 多幅图合在一起 本章所介绍内容概括如下. 一图胜千字,人们从视觉层更易获取和理解信息. 图形工作 R具有非常强大的绘图功能,看下面代码. > attach(mtcars) > plot(wt, mpg) > abline(lm(mpg~wt)) > title("Regression of MPG on Weight") > detach(m

Swift学习笔记四:数组和字典

最近一个月都在专心做unity3d的斗地主游戏,从早到晚,最后总算是搞出来了,其中的心酸只有自己知道.最近才有功夫闲下来,还是学习学习之前的老本行--asp.net,现在用.net做项目流行MVC,而不是之前的三层,既然技术在更新,只能不断学习,以适应新的技术潮流! 创建MVC工程 1.打开Visual studio2012,新建MVC4工程 2.选择工程属性,创建MVC工程 3.生成工程的目录 App_Start:启动文件的配置信息,包括很重要的RouteConfig路由注册信息 Conten

老男孩培训视频听课笔记四(在51cto上听的)

实际操作:     1.创建一个目录 mkdir 语法:mkdir [-mp] [目录名称]            一般与配合cd tree pwd等命令来实现,整个操作     2.建议一个文件 利用touch命令来完成 语法:touch [path]/filename            批量创建文件:        for f in `seq 1000`;do touch $f.txt;done         创建文件的命令很多:vi echo> > cat等命令      3.文件

NLTK学习笔记(四):自然语言处理的一些算法研究

自然语言处理中算法设计有两大部分:分而治之 和 转化 思想.一个是将大问题简化为小问题,另一个是将问题抽象化,向向已知转化.前者的例子:归并排序:后者的例子:判断相邻元素是否相同(与排序). 这次总结的自然语言中常用的一些基本算法,算是入个门了. 递归 使用递归速度上会受影响,但是便于理解算法深层嵌套对象.而一些函数式编程语言会将尾递归优化为迭代. 如果要计算n个词有多少种组合方式?按照阶乘定义:n! = n*(n-1)*...*1 def func(wordlist): length = le

悟道—位IT高管20年的职场心经(读书笔记四)

悟道--一位IT高管20年的职场心经 第四章 人情练达即文章 "问世间情为何物,直教人生死相许" 那是说的爱情. 职场中的人情实在没那么浪漫, 很多时候是冷冰冰的, 但是你必须去面对, 以积极的.正面的心态去面对. 不但要面对,还要苦心经营. 1.1  谁都别惯着:下属不能惯 学会安排事情,分担事情. 1.2  谁都别惯着:老板不能惯 怎么样去和不同性格的老板交流,老板也有他自己的不足的地方,在这种情况下,最好是自己有自己的解决问题的方法. 1.3  谁都别惯着:客户不能惯 对客户,有