# Transition:添加弹出过渡效果

通过鼠标的单击、获得焦点,被点击或对元素任何改变中触发,并平滑地以动画效果改变CSS的属性值。

W3C-transition

MDN-transition

在CSS中创建简单的过渡效果可以从以下几个步骤来实现:

第一,在默认样式中声明元素的初始状态样式;

第二,声明过渡元素中点值样式,比如悬浮状态;

第三,在默认样式中通过添加过渡函数,添加一些不同的样式。

  • transition:为一个元素在不同状态之间切换的时候定义不同的过渡效果。
  • transition: property | duration | timing function | delay ;
    • property:过渡效果的 CSS 属性的名称。
    • duration:完成过渡效果需要多少秒或毫秒。
    • transition-timing-function:规定速度效果的速度曲线。
    • delay:过渡效果何时开始。[规定在过渡效果开始之前需要等待的时间,以秒或毫秒计。]
    • 默认值:all 0 ease 0
  • 属性语法值及解释
    • transition-property: none | all | property;

    • transition-duration: time;[规定完成过渡效果需要花费的时间(以秒或毫秒计)。默认值是 0,意味着不会有效果]
    • transition-timing-function: linear|ease|ease-in|ease-out|ease-in-out|cubic-

      bezier(n,n,n,n); 详解
    • transition-delay: time;
transition-timing-function: linear  /* the same speed */
: ease /* slow-fast-slow */
: ease-in /* slow start*/
: ease-out /* slow end */
: ease-in-out /*slow start-slow end*/
: cubic-bezier(n,n,n,n); /*define your own values in a cubic-bezier function*/
▲ 单个属性:
{
width:100px; /*初始状态*/
background:blue; /*需要设置背景色或border,否则效果不可见。*/
transition-property: width;
transition-duration: 2s;/*效果过渡时间不可缺省,否则虽然可触发,但无过渡效果。*/
}
div:hover{width:300px;} /*目标值及触发*/ /*也可集合使用,如下*/
transition: width 2s;
▲ 多个属性:
div
{
width:100px;
height:100px;
background-color:red;
border:3px solid yellow;
transition:background-color 2s,border 2s,width 2s,height 2s;border:10px dotted black; /*多属性建议使用 {transition:all 2s} */
} div:hover
{
width:300px;
height:300px;
background-color:green;
border:10px dotted black;
}
  • transition可以写在起始css中,也可以写在中点css中。

    • transition写在起始css中,效果覆盖起始中点/中点终止 的整个周期。
    • transition写在中点css中,效果只覆盖中点终止
  • transition写在哪个标签,就表示过渡效果向谁进行,例如:
<div></div>
div {
width: 100px;
height: 100px;
background-color: red;
transition: width 2s;
}
/*由div:hover中值状态返回div初始状态,width有2S的过渡;其他属性无过渡效果*/
div:hover {
width: 300px;
background-color: green;
transition: background-color 2s;
}
/*由div初始状态——div:hover中值状态,过渡效果有width、background-color;其他属性无过渡效果*/

除非对返回过渡有特殊要求,否则一般将transition写在起始css中。

# Transition:添加弹出过渡效果的更多相关文章

  1. JSP中添加弹出框

    JSP中添加弹出框 %> <script language="javascript" type="text/javascript"> aler ...

  2. 原生Js_实现简单的下拉折叠菜单(添加弹出动画效果)

    用javascript实现简单的下拉折叠菜单效果 实现步骤 (a)获得各操作的dom对象: (b)在所有菜单按钮对象上添加单击事件: (c)设置所有菜单按钮样式为空,并将当前按钮的样式设置为“acti ...

  3. JS来添加弹出层,并且完成锁屏

    上图 <html> <head> <title>弹出层</title> <style type="text/css"> ...

  4. iOS添加弹出菜单

    最近接触的项目需要实现一个弹出窗,类似于点击微信navigation bar右上角的bar button所展现的弹出窗,最终效果如下: Demo代码存放在https://github.com/LuoD ...

  5. openlayers添加弹出框

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. Bootstrap-Plugin:弹出框(Popover)插件

    ylbtech-Bootstrap-Plugin:弹出框(Popover)插件 1.返回顶部 1. Bootstrap 弹出框(Popover)插件 弹出框(Popover)与工具提示(Tooltip ...

  7. Css动画形式弹出遮罩层,内容区上下左右居中于不定宽高的容器中

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

  8. JavaScript插件——弹出框

    (JavaScript插件——弹出框) 前言 阅读之前您也可以到Bootstrap3.0入门学习系列导航中进行查看http://www.cnblogs.com/aehyok/p/3404867.htm ...

  9. 弹出框,先弹出遮罩有透明度灰色100%高宽,置顶z-index:999---再弹出框最顶部z-index:9999

    <div class="mask"></div> <div class="maskbox"> <form id=&qu ...

随机推荐

  1. codeforces 667B B. Coat of Anticubism(水题)

    题目链接: B. Coat of Anticubism time limit per test 1 second memory limit per test 256 megabytes input s ...

  2. node fs模块

    Node.js的文件系统的Api //公共引用 var fs = require('fs'), path = require('path'); 1.读取文件readFile函数 //readFile( ...

  3. lua 与C通过c api传递table (2)

    本文转自http://blog.csdn.net/a_asinceo/article/details/49907903(感谢...) 一.单个参数的传递 首先我们在Lua中注册一个C类PJYCallb ...

  4. 关于 .dyib 文件

    .dylib 意味着这是一个动态链接库. libz.dylib 是提供zip压缩.解压缩的库. 库的接口请 #import "zlib.h"

  5. 关于HibernateDaoSupport中的getHibernateTemplate().execute及executeFind方法

    转自:https://blog.csdn.net/angus_17/article/details/8501668 1. 这两个方法都是为了Spring在接管Hibernate之后,可以对Hibern ...

  6. ol 与ul 的区别

    1 <!DOCTYPE html> <html> <body> <ul> <li>咖啡</li> <li>牛奶< ...

  7. View Programming Guide for iOS ---- iOS 视图编程指南(四)---Views

    Views Because view objects are the main way your application interacts with the user, they have many ...

  8. 洛谷 - P2055 - 假期的宿舍 - 最大流

    https://www.luogu.org/problemnew/show/P2055 这是一个错误的示范. 一开始觉得就找一条路从外校同学连到本校同学然后最终从周末回家的同学流出,每个人睡后一个人的 ...

  9. 前端代码规范(转载 http://codeguide.bootcss.com/)

    http://codeguide.bootcss.com/ HTML 语法 HTML5 doctype 语言属性(Language attribute) 字符编码 IE 兼容模式 引入 CSS 和 J ...

  10. 左耳朵耗子:我对 GitLab 误删除数据库事件的几点思考

    参考链接:https://www.infoq.cn/article/some-thoughts-on-gitlab-accidentally-deleting-database 太平洋时间 2017 ...