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 &#160;css &#160;&#160;transition&#160;Animation&#160;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"> <! ...
随机推荐
-
SharePoint 2010 数据库xxx的事务日志已满
接到领导安排,说客户有问题 请求协助解决,对方给我展示的错误日志,如下: 数据库'WSS_Content_xxxx'的事务日志已满.若要查明无法重用日志中的空间的原因,请参阅sy.databases中 ...
-
RequireJS 模块的定义与加载
模块不同于传统的脚本文件,它良好地定义了一个作用域来避免全局名称空间污染.它可以显式地列出其依赖关系,并以函数(定义此模块的那个函数)参数的形式将这些依赖进行注入,而无需引用全局变量.RequireJ ...
-
nginx下php频繁卡死502
解决:[WARNING] fpm_children_bury(), line 215: child 2736 (pool default) exited on signal 15 SIGTERM af ...
-
refresh的停车场 分类: 栈和队列 2015-06-18 17:13 26人阅读 评论(0) 收藏
refresh的停车场 TimeLimit: 1000ms Memory limit: 65536K 题目描述 refresh最近发了一笔横财,开了一家停车场.由于土地有限,停车场内停车数量有限,但是 ...
-
hdu1710(Binary Tree Traversals)(二叉树遍历)
Binary Tree Traversals Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
-
图论(差分约束系统):POJ 1275 Cashier Employment
Cashier Employment Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7651 Accepted: 288 ...
-
Elasticsearch VS Solr
最近公司用到了ES搜索引擎,调研发现大公司常用的搜索引擎还有Solr. 鉴于 Lucene 强大的特性和稳定性,有很多种基于 Lucene 封装的企业级搜索平台.其中最流行有两个:Apache Sol ...
-
Dubbo底层采用Socket进行通信详解
由于Dubbo底层采用Socket进行通信,自己对通信理理论也不是很清楚,所以顺便把通信的知识也学习一下. n 通信理论 计算机与外界的信息交换称为通信.基本的通信方法有并行通信和串行通信两种. 1 ...
-
Spring Boot(十二)单元测试JUnit
一.介绍 JUnit是一款优秀的开源Java单元测试框架,也是目前使用率最高最流行的测试框架,开发工具Eclipse和IDEA对JUnit都有很好的支持,JUnit主要用于白盒测试和回归测试. 白盒测 ...
-
用Python做股市数据分析(二)
本文由 伯乐在线 - 小米云豆粥 翻译.未经许可,禁止转载!英文出处:Curtis Miller.欢迎加入翻译组. 这篇博文是用Python分析股市数据系列两部中的第二部,内容基于我在犹他大学 数学3 ...