Weird behavior when rotating an element on hover

前端 未结 2 1494
一向
一向 2020-12-22 05:23

Given these two examples.

Using Hover

2条回答
  •  伪装坚强ぢ
    2020-12-22 05:48

    It seems a browser bug (at least on Chrome) as it works fine if your try the code on Firefox.

    Let refer to the the specification to explain this. Here is all the different cases of how interpolation between transform should work.

    In our case, we will consider the last point where we don't have the same number of transform functions and the browser should handle this by adding the identity transform function from the missing list and in our case it should be rotate(0).

    So technically a transition from translate(-50%) to translate(-50%) rotate(360deg) should be the same as a transition from translate(-50%) rotate(0) to translate(-50%) rotate(360deg).

    Unless, I am missing something this is for sure a bug as in the case when rotate(360deg) is used alone, Chrome is handling this fine using the second point (when one value is none) which is almost the same as the last point.

提交回复
热议问题