过渡(transition)
简写transition()
可以有四个值
第一个是过渡属性(color…)如果多个(all)没有(none)
第二个是过渡时间(1s)
第三个是过渡函数:
- ease(默认)
- linear(匀速)
- ease-in(慢速开始,加速效果)
- ease-out(慢速结束,慢速效果)
- ease-in-out(慢速开始结束,先加速后减速效果)
第四个是过渡延迟
案例:由红色变黄(并不是四个值每次都需要,根据自己需要选择)
<div id="test"></div>
<style>
#test{
margin: 150px auto;
width: 200px;
height: 200px;
background: red;
transition: background-color 1s ease-in 1s;
}
#test:hover{
background-color: yellow;
}
</style>