我可以在转换中指定转换属性吗?
Can I specify the transform attribute in transition?
最常见的情况是这样的:
transition: background-color 0.2s,
transform 1s;
但我想指定由转换控制的转换属性,如
transition: transform scale 1s,
transform skew 0.5s,
transform rotate 2s;
我试过了,没用。
使用animation
代替transition
并设置所有时间(1s
+0.5s
+2s
)并在@keyframes
中划分它您要为每个 transform
属性
设置的时间
div{
width: 100px;
height: 100px;
background: red;
}
div:hover{
animation: move 2.5s;
}
@keyframes move {
0% {
transform: scale(3);
}
35% {
transform: scale(3) skew(180deg);
}
50%{
transform: scale(3) skew(180deg) rotate(70deg);
}
}
<div></div>
最常见的情况是这样的:
transition: background-color 0.2s,
transform 1s;
但我想指定由转换控制的转换属性,如
transition: transform scale 1s,
transform skew 0.5s,
transform rotate 2s;
我试过了,没用。
使用animation
代替transition
并设置所有时间(1s
+0.5s
+2s
)并在@keyframes
中划分它您要为每个 transform
属性
div{
width: 100px;
height: 100px;
background: red;
}
div:hover{
animation: move 2.5s;
}
@keyframes move {
0% {
transform: scale(3);
}
35% {
transform: scale(3) skew(180deg);
}
50%{
transform: scale(3) skew(180deg) rotate(70deg);
}
}
<div></div>