jQuery超酷平面式时钟效果代码分享


本文实例讲述了jQuery超酷平面式时钟效果代码。分享给大家供大家参考。具体如下:
jQuery制作的超酷平面式时钟效果,把日期和时间通过横向刻度条展现,经测试效果非常酷,是一个很不错的学习实例。
这里我们还要提到之前实现的另一个特别新颖的时间显示样式:js实现温度计时间样式,两者都完全突破了传统的时钟概念,感兴趣的各位可不要错过了哈。

运行效果图:----------------------查看效果 下载源码-----------------------

小提示:浏览器中如果不能正常运行,可以尝试切换浏览模式。
为大家分享的jQuery超酷平面式时钟效果代码如下

<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="JS代码,时钟,日期,刻度条,jQuery" />
<meta name="description" content="jQuery制作的超酷平面式时钟效果,更多时钟,日期,刻度条,jQuery请访问phpstudyJS代码频道。" />
<title>jQuery制作的超酷平面式时钟效果_phpstudy</title>

<style type="text/css">

body { background:#bae1ea url(back.jpg) 50% 0px no-repeat; color:#000; }

/* container for clock */
#wrap { position:relative; margin: 100px auto 0; width:700px; height:440px; background:url("slider clock(trans).png") no-repeat top left; border-style:solid; border-width:1px; overflow:hidden; }

/* style background and size of all sliding divs */
#wrap div { position:absolute; margin-left:-700px; width:1400px; height:40px; background:url("slider clock(trans).png") repeat-x; } 

/* specific position and background position for sliding divs */
#wrap #day { top:40px; background-position:0 -440px; }

#wrap #month { top:120px; background-position:0 -480px; }

#wrap #date { top:200px; background-position:0 -520px; }

#wrap #hour { top:280px; background-position:0 -560px; }

#wrap #min { top:320px; background-position:0 -600px; }

#wrap #sec { top:400px; background-position:0 -640px; }

#title { margin:20px auto; width:550px; text-align:center; }

#other { margin:10px auto; width:550px; text-align:center; }

</style>



<script type="text/javascript" src="jquery.js"> </script>

<script>

 $(document).ready(function(){

  function checktime(olddel){

   var now = new Date();

    var nowdel = now.getDay() + "|" + now.getMonth() + "|" + now.getDate() + "|" + now.getHours() + "|" + now.getMinutes() + "|" + now.getSeconds();

    if ( olddel != nowdel ) {

     var oldsplit = olddel.split("|");
     var nowsplit = nowdel.split("|");

     if ( oldsplit[5] != nowsplit[5] ) {

      clock_slide('#sec',nowsplit[5],11);
      if ( oldsplit[4] != nowsplit[4] ) {

       clock_slide('#min',nowsplit[4],11);
       if ( oldsplit[3] != nowsplit[3] ) {

        clock_slide('#hour',nowsplit[3],28);
        if ( oldsplit[2] != nowsplit[2] ) {

         clock_slide('#day',nowsplit[0],100);
         clock_slide('#date',(nowsplit[2]-1),22);

         if ( oldsplit[1] != nowsplit[1] ) {
          clock_slide('#month',nowsplit[1],57);

         };
        };
       };
      };
     };
    };

    function clock_slide(which,howmuch,multiple){
     $(which).stop().animate({marginLeft: ((howmuch*multiple)-700)+'px'}, 250, 'linear');
    };

    setTimeout(function(){checktime(nowdel);}, 250);


  };

   checktime("0|0|0|0|0|0");

 });

</script>



</head>

<body>



 <div id="wrap">

  <div id="day"> </div>

  <div id="month"> </div>
  <div id="date"> </div>
  <div id="hour"> </div>
  <div id="min"> </div>
  <div id="sec"> </div>

 </div> <!-- End "wrap" -->


<div style="text-align:center;clear:both">
<p>来源:<a href="http://www.phpstudy.net" target="_blank">vonholdt</a> 代码整理:<a href="http://www.phpstudy.net" target="_blank">phpstudy</a> 感谢:<a href="http://www.phpstudy.net" target="_blank">liulisuo</a></p>
<p>转载请注明出处,此代码仅供学习交流,请勿用于商业用途。</p>
</div>
</body>
</html>

以上就是为大家分享的jQuery超酷平面式时钟效果代码,希望大家可以喜欢。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3