关键帧动画从动画 div 中移除偏斜
Keyframe animation removing skew from div on animation
我对 div 应用了倾斜变换,我想在页面加载时为其设置动画。
当我使用关键帧动画时,倾斜在动画过程中被移除,然后在动画完成后 "pops" 到位。
如何在动画进行时保持应用于 div 的倾斜?
div {
-webkit-transform:skew(-197deg);
-moz-transform:skew(-197deg);
transform:skew(-197deg);
width: 200px;
margin-left: 40px;
animation: 1s ease-in-out 0s 1 slideInFromLeft;
}
@keyframes slideInFromLeft {
0% {
transform: translateX(-100%);
opacity: 0;
}
60% {
opacity: 0.5;
}
100% {
transform: translateX(0);
opacity: 1;
}
}
<div>Hello, this is a skewed div that does not stay skewed when the animation is in progress.</div>
您需要将 skew
添加到动画中,否则动画规则将覆盖它。
div {
-webkit-transform:skew(-197deg);
-moz-transform:skew(-197deg);
transform:skew(-197deg);
width: 200px;
margin-left: 40px;
animation: 1s ease-in-out 0s 1 slideInFromLeft;
}
@keyframes slideInFromLeft {
0% {
transform: skew(-197deg) translateX(-100%);
opacity: 0;
}
60% {
opacity: 0.5;
}
100% {
transform: skew(-197deg) translateX(0);
opacity: 1;
}
}
<div>Hello, this is a skewed div that does not stay skewed when the animation is in progress.</div>
我对 div 应用了倾斜变换,我想在页面加载时为其设置动画。
当我使用关键帧动画时,倾斜在动画过程中被移除,然后在动画完成后 "pops" 到位。
如何在动画进行时保持应用于 div 的倾斜?
div {
-webkit-transform:skew(-197deg);
-moz-transform:skew(-197deg);
transform:skew(-197deg);
width: 200px;
margin-left: 40px;
animation: 1s ease-in-out 0s 1 slideInFromLeft;
}
@keyframes slideInFromLeft {
0% {
transform: translateX(-100%);
opacity: 0;
}
60% {
opacity: 0.5;
}
100% {
transform: translateX(0);
opacity: 1;
}
}
<div>Hello, this is a skewed div that does not stay skewed when the animation is in progress.</div>
您需要将 skew
添加到动画中,否则动画规则将覆盖它。
div {
-webkit-transform:skew(-197deg);
-moz-transform:skew(-197deg);
transform:skew(-197deg);
width: 200px;
margin-left: 40px;
animation: 1s ease-in-out 0s 1 slideInFromLeft;
}
@keyframes slideInFromLeft {
0% {
transform: skew(-197deg) translateX(-100%);
opacity: 0;
}
60% {
opacity: 0.5;
}
100% {
transform: skew(-197deg) translateX(0);
opacity: 1;
}
}
<div>Hello, this is a skewed div that does not stay skewed when the animation is in progress.</div>