[转] CSS transition
https://css-tricks.com/almanac/properties/t/transition/
The transition property is a shorthand property used to represent up to four transition-related longhand properties:
.example {
transition: [transition-property] [transition-duration] [transition-timing-function] [transition-delay];
}
These transition properties allow elements to change values over a specified duration, animating the property changes, rather than having them occur immediately. Here is a simple example that transitions the background color of a <div> element on :hover:
div {
transition: background-color 0.5s ease;
background-color: red;
}
div:hover {
background-color: green;
}
That div will take half a second when the mouse is over it to turn from red to green. Here is a live demonstration of such a transition:
You can specify a particular property as we have above, or use a value of "all" to refer to transition properties.
div {
transition: all 0.5s ease;
background: red;
padding: 10px;
}
div:hover {
background: green;
padding: 20px;
}
In this above example, both background and padding will transition, due to the value “all” specified for the transition-property portion of the shorthand.
You may comma separate value sets to do different transitions on different properties:
div {
transition: background 0.2s ease,
padding 0.8s linear;
}
For the most part, the order of the values does not matter -- unless a delay is specified. If you specify a delay, you must first specify a duration. The first value that the browser recognizes as a valid time value will always represent the duration. Any subsequent valid time value will be parsed as the delay.
Some properties cannot be transitioned because they are not animatable properties. See the spec for a full list of which properties are animatable.
By specifying the transition on the element itself, you define the transition to occur in both directions. That is, when the styles are changed (e.g. on hover on), they properties will transition, and when the styles change back (e.g. on hover off) they will transition. For example, the following demo transitions on hover, but not on hover off:
This happens because the transition has been moved to the :hover state selector and there is no matching transition on the selector that targets the element directly without the :hover state.
For compatibility in all supporting browsers, vendor prefixes are required, with the standard syntax declared last:
.example {
-webkit-transition: background-color 500ms ease-out 1s;
-moz-transition: background-color 500ms ease-out 1s;
-o-transition: background-color 500ms ease-out 1s;
transition: background-color 500ms ease-out 1s;
}
IE10 (the first stable version of IE to support transition) does not require the -ms- prefix.
[转] CSS transition的更多相关文章
- Atitti css transition Animation differ区别
Atitti css transition Animation differ区别 1.1. transition的优点在于简单易用,但是它有几个很大的局限. 1 1.2. Transition ...
- Atitti css transition Animation differ区别
Atitti css transition Animation differ区别 1.1. transition的优点在于简单易用,但是它有几个很大的局限. 1 1.2. js 动态改变 st ...
- No.3 - CSS transition 和 CSS transform 配合制作动画
课程概述 作业提交截止时间:09-01 任务目的 深度理解掌握 transition-timing-function 以及它的意义 学会配合使用 CSS transform 和CSS transiti ...
- CSS transition 的默认值
语法 transition: property duration timing-function delay|initial|inherit; 示例: div { width: 100px; ...
- CSS transition & shorthand property order
CSS transition & shorthand property order shorthand property https://developer.mozilla.org/en-US ...
- CSS transition 过渡 详解
transition 过渡 IE10.Firefox.Chrome.Opera 支持 transition 属性. Safari 需要前缀 -webkit-. Chrome 25 以及更早版本需要前缀 ...
- Css transition
CSS的transition允许CSS的属性值在一定的时间区间内平滑地过渡.这种效果可以在鼠标单击.获得焦点.被点击或对元素任何改变中触发,并圆滑地以动画效果改变CSS的属性值. <!DOCTY ...
- css transition 实现滑入滑出
transition是css最简单的动画. 通常当一个div属性变化时,我们会立即看的变化,从旧样式到新样式是一瞬间的,嗖嗖嗖!!! 但是,如果我希望是慢慢的从一种状态,转变成另外一种状态,怎么办? ...
- css transition transform animation例子讲解
1.transition属性: transition属性是一个速记属性有四个属性:transition-property , transition-duration, transition-timin ...
- 鼠标hover某个元素时其属性表现Css transition 过渡效果(以宽高属性居中放大为例)
<!DOCTYPE html> <html> <head> </head> <body id="body"> <! ...
随机推荐
- android学习(2) 多线程的理解
多线程操作UI的运行原理: UI线程:首先启动app时,系统会自动启动一个UI线程,然后此线程会创建一个Looper(注:Looper构造函数会实例化一个MessageQueue的消息队列存在变量mQ ...
- deep learning framework(不同的深度学习框架)
常用的deep learning frameworks 基本转自:http://www.codeceo.com/article/10-open-source-framework.html 1. Caf ...
- 使用Python实现Hadoop MapReduce程序
转自:使用Python实现Hadoop MapReduce程序 英文原文:Writing an Hadoop MapReduce Program in Python 根据上面两篇文章,下面是我在自己的 ...
- Cow Marathon
poj1985:http://poj.org/problem?id=1985 题意:就是树的直径. 题解:直接DFS即可. #include<iostream> #include<c ...
- ios开发UI篇—在ImageView中添加按钮以及Tag的参数说明
ios开发UI篇—在ImageView中添加按钮以及Tag的参数说明 一.tag参数 一个视图通常都只有一个父视图,多个子视图,在开发中可以通过使用子视图的tag来取出对应的子视图.方法为Viewwi ...
- RESTful, 说说 http 的 patch method
最早的时候,我们只需要 GET 和 POST 方法,POST 方法的引入也只是为了消除 URL 过长,参数隐藏,上传文件的问题,完全和语义无关.接触到 RESTful 之后,我们开始思考 GET 和 ...
- jinfo命令(Java Configuration Info)
jinfo可以输出并修改运行时的java 进程的opts.用处比较简单,用于输出JAVA系统参数及命令行参数.用法是jinfo -opt pid 如:查看2788的MaxPerm大小可以用 jin ...
- 【HDOJ】1466 计算直线的交点数
找了个规律. #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXN 21 ...
- python换行写入文件
今天用python做写入文件时,碰到,写入的东西不能换行,打开写入的文件都是一行.后来发现需要在写入的字符后面加上+'\n'. 另外python需要追加写入文件的时候,是用这个方法f = open(' ...
- Objective-c知识小结
1.创建一个类产生.h和.m两个文件,.h中对用到的变量.方法作声明,.m文件中实现,导入时只导入.h文件,如果直接把方法写在.m文件中,未在.h文件中进行声明,则是私有方法 2.@interfac ...