Check out https://jsfiddle.net/u5L1dmvx/
transform: rotate3d(0, 0, 1, 45deg);
transform: rotate3d(1, 0, 0, 90deg);
Suppose I would like to perform two rotations. First rotate around z axis by 45 degrees and then rotate around x axis by 90 degrees.
How can I combine these two? I mean, this can be two questions.
In math, I would like to know, if I use transform: rotate3d(x, y, z, wdeg);
, how to calculate x
, y
, z
and w
for the combined effect?
In programming, is it possible to change style
of div
by js to combine these two? I mean, write code to apply a new rotation on an already rotated div
to achieve the combined effect.
UPDATE:
Currently I have a temporary brute answer:
transform: rotate3d(1, 0, 0, 90deg) rotate3d(0, 0, 1, 45deg);
But if the rotation operation list is long, style
of div
could become longer every time an operation is executed:
transform: rotate3d(1, 0, 0, 90deg) rotate3d(0, 0, 1, 45deg) rotate3d(1, 0, 0, 90deg) rotate3d(0, 0, 1, 45deg) rotate3d(1, 0, 0, 90deg) rotate3d(0, 0, 1, 45deg) rotate3d(1, 0, 0, 90deg) rotate3d(0, 0, 1, 45deg) rotate3d(1, 0, 0, 90deg) rotate3d(0, 0, 1, 45deg) rotate3d(1, 0, 0, 90deg) rotate3d(0, 0, 1, 45deg) rotate3d(1, 0, 0, 90deg) rotate3d(0, 0, 1, 45deg) rotate3d(1, 0, 0, 90deg) rotate3d(0, 0, 1, 45deg) rotate3d(1, 0, 0, 90deg) rotate3d(0, 0, 1, 45deg);
Is there a more elegant way?