通过js 插件控制图片旋转

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>旋转图片</title>
    <script type="text/javascript" src="coos.ui.rotate.js"></script>
</head>
<body>
    <div id="testdiv1" style="z-index:4; position: absolute; top:50%;  margin:0 auto; margin-top:-175px; left:50%; margin-left:-175px; width:350px; height:350px; background-image:url(shuijing.png)">
    </div>
    <div id="testdiv" style="z-index:10; position: absolute; top:50%;  margin:0 auto; margin-top:-175px; left:50%; margin-left:-175px;">
        <img alt="" id="theimage" border="0" src="star.png" />
    </div>
    <script type="text/javascript">
        var setTime;
        window.onload = function () {
            GetRTime();
        }
        function GetRTime() {
            rotateLeft('theimage', 1); //顺时针1度旋转
            var divObj = document.getElementById("testdiv");
            var divObj_Width = document.getElementById("testdiv").offsetHeight;
            var divObj_Height = document.getElementById("testdiv").offsetWidth;
            divObj.style.marginLeft = "-" + (divObj_Width / 2) + "px";
            divObj.style.marginTop = "-" + (divObj_Height / 2) + "px";
            //rotateRight('theimage', 90); //逆时针90度旋转
            setTime = setTimeout(function () { GetRTime() }, 100)
        }
    </script>
</body>
</html>

 附件:https://files.cnblogs.com/wangbogo/%E6%97%8B%E8%BD%AC%E5%9B%BE%E7%89%87-%E6%B0%B4%E6%99%B6%E7%90%83.rar

posted on 2012-12-26 11:16  wboweb  阅读(3504)  评论(0编辑  收藏  举报

导航