如何固定js或CSS中的图片位置?我有摩天轮,我希望所有图像在旋转时都应保持直立。
我想要这样:http://jsdo.it/proppy/plUk/fullscreen看到粉红色三角形旋转时位置固定。

这是我的:http://letmespeakenglish.net/wheel/index.html

有什么帮助吗?欢迎任何建议。
谢谢您的帮助。

最佳答案

这是工作中的example

好了,要解决您的问题,就必须旋转整个车轮,以使各个图像反向旋转。
因此,将脚本更改为此应该可以解决该问题:

<script src="http://code.jquery.com/jquery-1.6.3.min.js" type="text/javascript"></script>
<script>
    var rotation = 0
    setInterval(function() {
        $('div.#wheel').css({
            "-moz-transform": "rotate(" + rotation + "deg)",
            "-webkit-transform": "rotate(" + rotation + "deg)",
            "-o-transform": "rotate(" + rotation + "deg)",
            "-ms-transform": "rotate(" + rotation + "deg)"
        });

        $('.fa').css({
        "-moz-transform": "rotate("+(-rotation)+ "deg)",
        "-webkit-transform": "rotate("+(-rotation)+ " deg)",
        "-o-transform": "rotate("+(-rotation)+ " deg)",
        "-ms-transform": "rotate("+(-rotation)+ " deg)"
    });

    rotation = (rotation + 10) % 361
    }, 500);
</script>


当您注视时间过长时,您会感到恶心。我的意思是摩天轮,而不是代码。

09-25 16:56
查看更多