过渡动画一个效果到另一个效果,经常和hover一起,transition:要过渡的属性 花费时间 运动曲线 何时开始,后两者可以省略,运动曲线默认ease。
过渡的属性可以是宽度、高度、背景颜色、内外边距等,如果想要所有的属性都过渡写all。
谁做过渡给谁写
div {
width: 200px;
height: 100px;
background-color: pink;
/* 如果写多个属性 用逗号隔开 */
transition: width 1s ease 0s, height 1s ease 1s;
transition: all 1s;
}
/* div:hover {
width: 400px;
} */
/* 不好看 用过渡来坐
谁想过渡给谁家 */
div:hover {
width: 400px;
height: 200px;
background-color: skyblue;
}