[英]Replace @keyframes in css with transitions
The platform were I work does not support @keyframes because of security reasons with the @. 我使用的平台由于安全原因,不支持@keyframes。 My question is if I can replace it with some other css trick.
我的问题是,是否可以将其替换为其他CSS技巧。 For example I have this code:
例如,我有以下代码:
.cubo {
animation:giro 25s infinite linear;
}
@keyframes giro {
0% {transform: rotateX(0deg) rotateY(0deg);}
100% {transform: rotateX(1080deg) rotateY(360deg);
}
}
Can I replace it with transitions or transforms to avoid using the @? 我可以将其替换为转换或转换以避免使用@吗? (no javascript supported either).
(也不支持javascript)。
You could instead make it a transition by multiplying the transition duration, rotateX
, and rotateY
values all by a common factor x
and applying the transition class on page load. 您可以通过过渡乘以持续,而不是使它成为一个过渡,
rotateX
和rotateY
值全部由一个共同的因子x
和应用在页面加载的过渡类。 In my example I multiplied them by 40, but you can go as high as you want but I wouldn't go too high because the processor might overload at some point and break the page. 在我的示例中,我将它们乘以40,但是您可以将其设置为任意高,但不会过高,因为处理器可能会在某些时候过载并破坏页面。 This runs for 1000 seconds, not many people will stay on a page past that
这个过程持续了1000秒,没有多少人会停留在页面上
Here is a live demo of that approach 这是该方法的现场演示
/* CSS */
.cubo {
/* ...Your other code... */
transition: all 1000s linear;
}
.animate {
-webkit-transform: rotateX(43200deg) rotateY(14400deg);
-moz-transform: rotateX(43200deg) rotateY(14400deg);
-o-transform: rotateX(43200deg) rotateY(14400deg);
-ms-transform: rotateX(43200deg) rotateY(14400deg);
transform: rotateX(43200deg) rotateY(14400deg);
}
/* Javascript (ran on page load) */
document.getElementsByClassName('cubo')[0].classList.add('animate');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.