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的更多相关文章

  1. Atitti css transition Animation differ区别

    Atitti  css   transition Animation differ区别 1.1. transition的优点在于简单易用,但是它有几个很大的局限.  1 1.2. Transition ...

  2. Atitti  css   transition Animation differ区别

    Atitti  css   transition Animation differ区别 1.1. transition的优点在于简单易用,但是它有几个很大的局限.  1 1.2. js 动态改变 st ...

  3. No.3 - CSS transition 和 CSS transform 配合制作动画

    课程概述 作业提交截止时间:09-01 任务目的 深度理解掌握 transition-timing-function 以及它的意义 学会配合使用 CSS transform 和CSS transiti ...

  4. CSS transition 的默认值

    语法 transition: property duration timing-function delay|initial|inherit; 示例: div {   width: 100px;    ...

  5. CSS transition & shorthand property order

    CSS transition & shorthand property order shorthand property https://developer.mozilla.org/en-US ...

  6. CSS transition 过渡 详解

    transition 过渡 IE10.Firefox.Chrome.Opera 支持 transition 属性. Safari 需要前缀 -webkit-. Chrome 25 以及更早版本需要前缀 ...

  7. Css transition

    CSS的transition允许CSS的属性值在一定的时间区间内平滑地过渡.这种效果可以在鼠标单击.获得焦点.被点击或对元素任何改变中触发,并圆滑地以动画效果改变CSS的属性值. <!DOCTY ...

  8. css transition 实现滑入滑出

    transition是css最简单的动画. 通常当一个div属性变化时,我们会立即看的变化,从旧样式到新样式是一瞬间的,嗖嗖嗖!!! 但是,如果我希望是慢慢的从一种状态,转变成另外一种状态,怎么办?  ...

  9. css transition transform animation例子讲解

    1.transition属性: transition属性是一个速记属性有四个属性:transition-property , transition-duration, transition-timin ...

  10. 鼠标hover某个元素时其属性表现Css transition 过渡效果(以宽高属性居中放大为例)

    <!DOCTYPE html> <html> <head> </head> <body id="body"> <! ...

随机推荐

  1. sql server 查询表某个字段不重复数据

    SELECT TOP (500) ID, Personname, Personcode, Telphone, Fraction into temp3 FROM Records AS a WHERE ( ...

  2. mmap内存映射复习

    c语言初学时,比较常见的一个习题就是实现cp. 使用c库实现的cp就不赘述了. 最近工作用到内存映射,就拿来练下手,复习一下mmap的用法. 很简单,将目标文件和源文件映射到内存,然后使用memcpy ...

  3. 支付宝openssl漏洞肆虐 互联网巨头称目前已修复

    支付宝openssl漏洞肆虐 互联网巨头称目前已修复 金山毒霸安全专家李铁军表示,这个漏洞使黑客可以远程读取https服务器的随机64KB内存,“只要这个黑客有耐心多捕获多分析那些64KB的数据,用户 ...

  4. Life Forms

    poj3294:http://poj.org/problem?id=3294 题意:就是求n个串的中一个最大的子串,这个子串在超过n/2的串中出现. 题解:这是一道好题.首先一种解法就是用后缀数组来搞 ...

  5. 同样版本的jstl,都是jstl1.2版本,有个有问题,另一个没有问题

    问题是这样的,最近部署一个项目,发现每次访问首页的时候老是报如下的错误: org.springframework.web.util.NestedServletException: Handler pr ...

  6. C语言嵌入式系统编程修炼之六:性能优化

    使用宏定义 在C语言中,宏是产生内嵌代码的唯一方法.对于嵌入式系统而言,为了能达到性能要求,宏是一种很好的代替函数的方法. 写一个"标准"宏MIN ,这个宏输入两个参数并返回较小的 ...

  7. Delphi WebBrowser控件的使用(大全 good)

    Delphi WebBrowser控件的使用 WebBrowser控件属性:1.Application      如果该对象有效,则返回掌管WebBrowser控件的应用程序实现的自动化对象(IDis ...

  8. Android JSON数据解析(数据传输)

    上篇随笔详细介绍了三种解析服务器端传过来的xml数据格式,而对于服务器端来说,返回给客户端的数据格式一般分为html.xml和json这三 种格式,那么本篇随笔将讲解一下json这个知识点,包括如何通 ...

  9. Git简明手册

    文/AbnerKang(简书作者)原 文链接:http://www.jianshu.com/p/d7a7ba4f2341?utm_campaign=maleskine& utm_content ...

  10. Spring dataSource

    1.何为dataSource DataSource 接口是 JDBC 2.0 API 中的新增内容,它提供了连接到数据源的另一种方法. 作为 DriverManager 工具的替代项,DataSour ...