transition过渡
一共有四个属性
transition-property: 属性; 监听所有具备动画过渡的属性(默认为all)
transition-duration:时间; 时间间隔,过渡完成的时间
transition-timing-function:运动函数; 过渡的运动函数
transition-delay: 时间; 延迟时间开始过渡
也可以一起写。也可以多写几次
举例
div{
width: 100px;
height: 100px;
background-color: red;
transition : all 1s linear 1s;
}
div:hover{
width: 200px;
height: 200px;
background-color: black;
}
<div></div>
初始状态
鼠标移上去,1s后开始过渡1s的时间完成过渡
div{
width: 100px;
height: 100px;
background-color: red;
transition: width 1s linear 1s, height 1s linear 2s;
}
div:hover{
width: 200px;
height: 200px;
background-color: black;
}
<div></div>
上面代码的意思是,鼠标移上去,背景色立马变成黑色,1s后宽度开始过渡,时间是1s。然后高度开始过渡,时间为1s。