找传奇、传世资源到传世资源站!

js实现钟表效果代码

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

from clipboardwindow.requestAnimFrame = (function(){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function( callback ){ window.setTimeout(callback, 1000 / 60); };})();//initialize the clock in a self-invoking function(function clock(){ var hour = document.getElementById("hour"), min = document.getElementById("min"), sec = document.getElementById("sec"); //set up a loop (function loop(){ requestAnimFrame(loop); draw(); })(); //position the hands function draw(){ var now = new Date(),//now then = new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0),//midnight diffInMil = (now.getTime() - then.getTime()),// difference in milliseconds h = (diffInMil/(1000*60*60)),//hours m = (h*60),//minutes s = (m*60);//seconds //rotate the hands accordingly sec.style.webkitTransform = "rotate(" (s * 6) "deg)"; hour.style.webkitTransform = "rotate(" (h * 30 (h / 2)) "deg)"; min.style.webkitTransform = "rotate(" (m * 6) "deg)"; } })();

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复