Is it allowed to use any decimal value in CSS keyframe animations?

僤鯓⒐⒋嵵緔 提交于 2019-11-28 09:49:09

When it comes to CSS it takes notice of percentages down to 2 decimal places and then stops. So you would be able to get 33.34% but not 33.3457% for use in your keyframes

I hope this helps.

Yes, you can use fractional part to define more precise keyframes percentages. But such precision is not clearly specified.

It's supported by all browsers that support CSS animations. But don't use too much decimals, strange behaviour may occur (especially above 5 digits).

I use that for complex animations with loops :

@keyframes{
    0%, 30%, 40%, 50%, 60%{
        top: 0px;
    }
    29.99999%, 39.99999%, 49.99999%, 59.99999%{
        top: 100px;
    }
    100%{
        top: 200px;
    }
}
/*
- 0px to 100px (30%)
- loop 3 times 0px to 100px (10% each, total 30%)
- 0px to 200px (40%)
*/

The SASS default precision is 3 digits and can be changed with --precision (cmd option) or Sass::Script::Number.precision

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!