标签:样式 star developer 其他 name 曲线 ... 函数 属性
第一,在默认样式中声明元素的初始状态样式;
第二,声明过渡元素中点值样式,比如悬浮状态;
第三,在默认样式中通过添加过渡函数,添加一些不同的样式。
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;
}
起始css
中,也可以写在中点css
中。
起始css
中,效果覆盖起始
→中点
/中点
→终止
的整个周期。中点css
中,效果只覆盖中点
→终止
。<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
中。
标签:样式 star developer 其他 name 曲线 ... 函数 属性
原文地址:https://www.cnblogs.com/deepblue775737449/p/9690848.html