CSS: transitions
CSS Transitions
CSS transitions allows you to change property values smoothly (from one value to another), over a given duration.
How to Use CSS Transitions?
To create a transition effect, you must specify two things:
- the CSS property you want to add an effect to
- 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.
The following example shows a 100px * 100px red <div> element. The <div> element has also specified a transition effect for the width property, with a duration of 2 seconds:
div {
width: 100px;
height: 100px;
background: red;
-webkit-transition: width 2s; /* Safari */
transition: width 2s;
}
The transition effect will start when the specified CSS property (width) changes value.
Now, let us specify a new value for the width property when a user mouses over the <div> element:
div:hover {
width: 300px;
}
Specify the Speed Curve of the Transition
The transition-timing-function property specifies the speed curve of the transition effect.
The transition-timing-function property can have the following values:
ease- specifies a transition effect with a slow start, then fast, then end slowly (this is default)linear- specifies a transition effect with the same speed from start to endease-in- specifies a transition effect with a slow startease-out- specifies a transition effect with a slow endease-in-out- specifies a transition effect with a slow start and endcubic-bezier(n,n,n,n)- lets you define your own values in a cubic-bezier function
The following example shows the some of the different speed curves that can be used:
#div2 {transition-timing-function: ease;}
#div3 {transition-timing-function: ease-in;}
#div4 {transition-timing-function: ease-out;}
#div5 {transition-timing-function: ease-in-out;}
Delay the Transition Effect
div {
width: 100px;
height: 100px;
background: red;
-webkit-transition: width 3s; /* Safari */
-webkit-transition-delay: 1s; /* Safari */
transition: width 3s;
transition-delay: 1s;
}
div:hover {
width: 300px;
}
Transition + Transformation
div {
width: 100px;
height: 100px;
background: red;
-webkit-transition: width 2s, height 2s, -webkit-transform 2s; /* Safari */
transition: width 2s, height 2s, transform 2s;
}
div:hover {
width: 300px;
height: 300px;
-webkit-transform: rotate(180deg); /* Safari */
transform: rotate(180deg);
}
div {
transition-property: width;
transition-duration: 2s;
transition-timing-function: linear;
transition-delay: 1s;
}
div {
transition: width 2s linear 1s;
}
CSS: transitions的更多相关文章
- CSS transitions深入理解
到底css transition是什么,我们来看w3c的解释: CSS Transitions allow property changes in CSS values to occur smooth ...
- [React] Use CSS Transitions to Avoid a Flash of Loading State
Based on research at Facebook, we know that if a user sees a flash of loading state, they perceive t ...
- [CSS] Transitions动画效果(1)
Transitions动画效果(1) 源码 https://github.com/YouXianMing/CSS-Animations/tree/master/Transitions 效果 细节
- 【CSS3】Advanced7:CSS Transitions
1.animate parts of your design without the need for the likes of JavaScrip 2.allowing smooth animati ...
- [CSS] CSS Transitions: Delays and Multiple Properties
<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery- ...
- CSS 3学习——transition 过渡
以下内容根据官方规范翻译以及自己的理解整理. 1.介绍 这篇文档介绍能够实现隐式过渡的CSS新特性.文档中介绍的CSS新特性描述了CSS属性的值如何在给定的时间内平滑地从一个值变为另一个值. 2.过渡 ...
- CSS3 Transitions, Transforms和Animation的使用
一.前言 CSS3动画相关的几个属性是:transition, transform, animation:分别理解为过渡,变换,动画.虽意义相近,但具体的功能和在CSS3中承担的工作有一定的差异. t ...
- CSS VS JS动画,哪个更快[译]
英文原文:https://davidwalsh.name/css-js-animation 原作者Julian Shapiro是Velocity.js的作者,Velocity.js是一个高效易用的js ...
- CSS-animations和transitions性能:浏览器到底做了什么?
CSS animations 和 transitions 的性能:浏览器到底做了什么?(译) 原文地址:http://blogs.adobe.com/webplatform/2014/03/18/cs ...
随机推荐
- linux基础命令(2)
1 nohup命令 如果你正在运行一个进程,而且你想在退出帐户/关闭终端之后继续运行相应的进程,可以使用这个命令,nohup就是不挂起的意思no hang up. 用法: nohup command ...
- beego——session控制
beego内置了session模块,目前session模块支持的后端引擎包括memory.cookie.file.mysql.redis.couchbase.memcache.postgres, 用户 ...
- C#框架及概念
EF框架
- SHELL —— grep命令+正则表达式
一 什么是正则 正则就是用一些具有特殊含义的符号组合到一起(称为正则表达式)来描述字符或者字符串的方法.或者说:正则就是用来描述一类事物的规则. 生活中处处都是正则: 比如我们描述:4条腿 你可能会想 ...
- django基础2: 路由配置系统,URLconf的正则字符串参数,命名空间模式,View(视图),Request对象,Response对象,JsonResponse对象,Template模板系统
Django基础二 request request这个参数1. 封装了所有跟请求相关的数据,是一个对象 2. 目前我们学过1. request.method GET,POST ...2. reques ...
- redmine集成git
步骤: redmine服务器 1. 在下载安装GIT客户端 下载地址: https://git-scm.com/ 2. 在redmine服务器上将对应项目的git镜像到本地(不是源码下载到本地 ...
- [MongoDB] 学习笔记(2)
1. Mac 安装mongodb: 官网下载mac版mongodb,解压到本地目录,如/Applications/mongodb,注意这里的地址是根更目录下的Applications,然后在根目录下创 ...
- springmvc RequestParam、RequestHeader
/** * 了解: * * @CookieValue: 映射一个 Cookie 值. 属性同 @RequestParam */ @RequestMapping("/testCookieVal ...
- sql 中 in 与 exist 的区别
可以 通过 where 条件 把 null的情况 筛选掉,已避免出现上述的情况. 1, exist 返回 true or false: in 返回 true unknow. not之后 not ...
- iOS设计模式探索
常用的 23 种设计模式 不管是 .NET 中的 C# 语言,还是 Java.VB.NET.C++ 或 Objective-C 语言,面向对象语言在设计模式的层面上都是相通的,只不过在设计模式的具体实 ...