div 회전

[.js] div 의 이동 2017. 9. 7. 15:39

<html>

<head>

</head>


<script  language="javascript"  >

 /*

rotate the div(a1) 

 */


 var div_a1;


 function init(){

  div_a1 = document.getElementById('a1');

   aa = setInterval("rotate_div()", 50); //  1000 = 1초   1초마다 roofing_func 를 실행하라.~

 }


 

 var aa = 0;

 

 function rotate_div(){

   //div_a1.style.left = e.offsetX - 20 + 'px';

   //div_a1.style.top = e.offsetY - 20 + 'px';     

   aa += 1;

   if( aa > 360 )

   aa = 0;

   div_a1.style.webkitTransform = 'rotate(' + aa + 'deg)';     

 }



</script>

    <body  onload="init();" >

        <div id="groundDiv"  style="position:relative; width:99%; height:99%; border:0x solid black;"></div>

        <div id='a1'  style="position:absolute; width:3px; height:50px; border:2px solid black;top:100px;left:100px  " ></div>

    </body>

</html>

 

Posted by 혜화초보
,