# Transition:添加弹出过渡效果
# Transition:添加弹出过渡效果
通过鼠标的单击、获得焦点,被点击或对元素任何改变中触发,并平滑地以动画效果改变CSS的属性值。
在CSS中创建简单的过渡效果可以从以下几个步骤来实现:
第一,在默认样式中声明元素的初始状态样式;
第二,声明过渡元素中点值样式,比如悬浮状态;
第三,在默认样式中通过添加过渡函数,添加一些不同的样式。
- transition:为一个元素在不同状态之间切换的时候定义不同的过渡效果。
- transition: property | duration | timing function | delay ;
- property:过渡效果的 CSS 属性的名称。
- duration:完成过渡效果需要多少秒或毫秒。
- transition-timing-function:规定速度效果的速度曲线。
- delay:过渡效果何时开始。[规定在过渡效果开始之前需要等待的时间,以秒或毫秒计。]
- 默认值:all 0 ease 0
- 属性语法值及解释:
- transition-property: none | all | property;
- [property name1,name2,name3...][[具有过渡效果属性](https://www.cnblogs.com/images/cnblogs_com/deepblue775737449/1000018/o_图像 1.jpg)]
- 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-property: none | all | property;
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写在
- 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:添加弹出过渡效果的更多相关文章
- JSP中添加弹出框
JSP中添加弹出框 %> <script language="javascript" type="text/javascript"> aler ...
- 原生Js_实现简单的下拉折叠菜单(添加弹出动画效果)
用javascript实现简单的下拉折叠菜单效果 实现步骤 (a)获得各操作的dom对象: (b)在所有菜单按钮对象上添加单击事件: (c)设置所有菜单按钮样式为空,并将当前按钮的样式设置为“acti ...
- JS来添加弹出层,并且完成锁屏
上图 <html> <head> <title>弹出层</title> <style type="text/css"> ...
- iOS添加弹出菜单
最近接触的项目需要实现一个弹出窗,类似于点击微信navigation bar右上角的bar button所展现的弹出窗,最终效果如下: Demo代码存放在https://github.com/LuoD ...
- openlayers添加弹出框
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Bootstrap-Plugin:弹出框(Popover)插件
ylbtech-Bootstrap-Plugin:弹出框(Popover)插件 1.返回顶部 1. Bootstrap 弹出框(Popover)插件 弹出框(Popover)与工具提示(Tooltip ...
- Css动画形式弹出遮罩层,内容区上下左右居中于不定宽高的容器中
<!DOCTYPE html> <html> <head> </head> <body id="body"> <! ...
- JavaScript插件——弹出框
(JavaScript插件——弹出框) 前言 阅读之前您也可以到Bootstrap3.0入门学习系列导航中进行查看http://www.cnblogs.com/aehyok/p/3404867.htm ...
- 弹出框,先弹出遮罩有透明度灰色100%高宽,置顶z-index:999---再弹出框最顶部z-index:9999
<div class="mask"></div> <div class="maskbox"> <form id=&qu ...
随机推荐
- 安装YouCompleteMe时,编译依赖的python版本不对
启动vim打开文件时出错: The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). YCM core library compile ...
- 【Codeforces 776B】Sherlock and his girlfriend
[题目链接] 点击打开链接 [算法] 将所有质数染成1,合数染成2即可 [代码] #include<bits/stdc++.h> using namespace std; #define ...
- margin -------总结(block inline 可置换元素)
margin在块元素.内联元素中的区别 block元素(块元素)大致有:P|H1|H2|H3|H4|H5|H6|UL|OL|PRE| DL | DIV | NOSCRIPT | BLOCKQUOTE ...
- 未能加载文件或程序集“Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyT
VS2008开发的网站,本地测试没问题,上传到服务器就出错,提示: 引用内容未能加载文件或程序集“Microsoft.ReportViewer.WebForms, Version=9.0.0.0, C ...
- const常量
1.不能给常量赋值 ; a=; 编译器报错:“a”: 不能给常量赋值
- View Controller Programming Guide for iOS---(三)---Using View Controllers in Your App
Using View Controllers in Your App Whether you are working with view controllers provided by iOS, or ...
- 任务22:课程介绍 & 任务23:Http请求的处理过程
任务23:Http请求的处理过程 http的处理过程 用户输入一个地址
- 所读STL文章摘要集结
在网上看了一些STL相关文章,这里将它们的摘要进行集结,方便以后查找. 1.黄常标,林俊义,江开勇.快速成形中STL文件拓扑信息的快速建立.2004 摘要:在分析现有建立拓扑信息方法的基础上,提出基于 ...
- Golang 读写锁RWMutex 互斥锁Mutex 源码详解
前言 Golang中有两种类型的锁,Mutex (互斥锁)和RWMutex(读写锁)对于这两种锁的使用这里就不多说了,本文主要侧重于从源码的角度分析这两种锁的具体实现. 引子问题 我一般喜欢带着问题去 ...
- hihocoder 1584 Bounce(找规律)
传送门 题意 略 分析 我们观察几张图 发现菱形的边长为n-1和m-1的公约数 将图简化一下 接下来我们计算只经过一次的点,分成两类 1.与边相交 num1=x+y 2.未与边相交,在菱形内 num2 ...