在X轴和Y轴上进行转换的Javascript(CSS 3D)
我用吐温在X轴和Y轴上旋转。但是我似乎找不到正确的javascript来编辑css 目标是一个div,使用下面的代码,它只旋转轴而忽略Y轴 它使用tweenjs在X轴和Y轴上进行转换的Javascript(CSS 3D),javascript,css,transform,tween,Javascript,Css,Transform,Tween,我用吐温在X轴和Y轴上旋转。但是我似乎找不到正确的javascript来编辑css 目标是一个div,使用下面的代码,它只旋转轴而忽略Y轴 它使用tweenjs function update() { target.style.left = position.x + 'px'; target.style.top = position.y + 'px'; target.style.webkitTransform = 'rotateY(' + Math.floor(posi
function update() {
target.style.left = position.x + 'px';
target.style.top = position.y + 'px';
target.style.webkitTransform = 'rotateY(' + Math.floor(position.rotation) + 'deg)';
target.style.MozTransform = 'rotateY(' + Math.floor(position.rotation) + 'deg)';
target.style.webkitTransform = 'rotateX(' + Math.floor(position.rotation) + 'deg)';
target.style.MozTransform = 'rotateY(' + Math.floor(position.rotation) + 'deg)';
}
如何告诉javascript在两个轴上旋转,而不是仅在一个轴上旋转?可以使用空格分隔参数。例如:
target.style.webkitTransform = 'rotateX(' + Math.floor(rotationX) + 'deg) rotateY(' + Math.floor(rotationY) + 'deg)';
(如果更改同一属性两次,将只覆盖以前的值。)