Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/378.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在X轴和Y轴上进行转换的Javascript(CSS 3D)_Javascript_Css_Transform_Tween - Fatal编程技术网

在X轴和Y轴上进行转换的Javascript(CSS 3D)

在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

我用吐温在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(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)';
(如果更改同一属性两次,将只覆盖以前的值。)