zoukankan      html  css  js  c++  java
  • 原生js可爱糖果数字时间特效

    原生js可爱糖果数字时间特效

     

    效果展示:
    http://hovertree.com/texiao/js/35/

    数字采用漂亮的糖果皮肤设计

    效果图:


    代码如下:

    复制代码
    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>js多彩的数字时钟_何问起</title><base target="_blank" />
        <style>a{color:blue;}</style>
    </head>
    <body>
        <div><h1>JS实现多彩的数字时钟</h1></div>
        <div id="time"></div>
        <div><br /><br /><a href="http://hovertree.com">何问起</a> <a href="http://hovertree.com/h/bjaf/o0yqj1ly.htm">说明</a> <a href="http://hovertree.com/texiao/">特效</a></div>
        <script>
        function getTime(){
            var date = new Date();
            var hours =formatTime(date.getHours());
            var minutes = formatTime(date.getMinutes());
            var seconds = formatTime(date.getSeconds());
            var $time = document.getElementById('time');
            $time.innerHTML=hours +"<img src='images/hm.png' style='margin:0 10px;' width='12' height='40'/>"+ minutes+"<img style='margin:0 10px;'  src='images/ms.png' width='12' height='40'/>"+ seconds;
    
            setTimeout("getTime()",500);
    
        }
        function formatTime(i){
            if(i<10&&i==1){
                i=  "<img src='images/0.png' width='40' height='60'/>"+"<img src='images/1.png' width='20' height='60'/>";
            }else if(i<10&&i!=1){
                i= "<img src='images/0.png' width='40' height='60'/>" + "<img src='images/"+i+".png' width='40' height='60'/>";
            }else{
    
                var j= i.toString().charAt(0);
                var z =i.toString().charAt(1);
               if(j<10 && z<10&&j!=1&&z!=1){
                   i = "<img src='images/"+j+".png' width='40' height='60'/>" + "<img src='images/"+z+".png' width='40' height='60'/>";
                }else if(j<10 && z<10&&j==1&&z!=1){
    
                   i = "<img src='images/1.png' width='20' height='60'/>" + "<img src='images/"+z+".png' width='40' height='60'/>";
    
               }else if(j<10 && z<10&&z==1&&j!=1){
                       i =  "<img src='images/"+j+".png' width='40' height='60'/>"+"<img src='images/1.png' width='20' height='60'/>";
    
               }else if(j<10 && z<10&&(j==1&&z==1)){
                   i="<img src='images/1.png' width='20' height='60'/>"+"<img src='images/1.png' width='20' height='60'/>";
               }
            }
    
            return i;
        }
        getTime();
        </script>
    </body>
    </html>
    复制代码

    -转载

  • 相关阅读:
    linux 上安裝lnmp
    html 禁用点击事件
    nftables 是什么? 提供什么功能? 如何使用?
    ESXi主机RAID卡_HBA卡_网卡 型号_固件_驱动查询
    Celery Beat定时任务
    Centos 7/8 安装Rabbit-MQ
    Celery 最佳实践
    Django 3.0 + Celery 4.4 + RabbitMQ
    C语言Socket示例
    深入理解计算机系统 — 读书笔记
  • 原文地址:https://www.cnblogs.com/wenJiaQi/p/6079567.html
Copyright © 2011-2022 走看看