In Chrome 'transform-origin' is invalid?

泄露秘密 提交于 2019-12-24 02:23:07

问题


My Chrome console returns Invalid CSS property name to a transform-origin CCS attribute as the site loads even though it works and I have a -webkit- prefixed version.

The target CSS looks like this:

-webkit-transform-origin: 0% 50%;
-moz-transform-origin: 0% 50%;
transform-origin: 0% 50%;

Is it really an issue?


回答1:


I've found the origin of my issue.

The problem is that -webkit- browsers don't accept the transform-origin attribute when it is isolated from a supporting attribute (an attribute that actually uses the transform-origin).

So, for example, if I use something like this, -webkit- assumes it is wrong:

#divOne{
   transform-origin:50% 50%;
   animation:jump 1s ease both;
}
@keyframe jump{
   from { transform: translateX(-20%) rotateY(-90deg); }
   to{ transform: translateX(0%) rotateY(0deg); }
}

It is wrong because the origin attribute is detached from the transform that is going to take use of it. Even though it works, it is not entirely correct on the browser's perspective.

It should be something like this to be correct:

#divOne{
   animation:jump 1s ease both;
}
@keyframe jump{
   from { transform: translateX(-20%) rotateY(-90deg); transform-origin:50% 50%; }
   to{ transform: translateX(0%) rotateY(0deg); transform-origin:50% 50%; }
}

Where both transforms are together on the same element.




回答2:


The answer to your question in simple terms is 'NO'. It is a perfectly valid property. There must be something else that's causing the error.

Read this:

https://docs.google.com/document/d/1UsKm0ywILw9cuTRYlkhqMYTdzNcih6sO15u1eCzGgP8/edit?pli=1#

and this

https://developer.mozilla.org/en-US/docs/Web/CSS/transform-origin#Browser_compatibility



来源:https://stackoverflow.com/questions/18894314/in-chrome-transform-origin-is-invalid

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