栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

原生JS实现的简单小钟表功能示例

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

原生JS实现的简单小钟表功能示例

本文实例讲述了原生JS实现的简单小钟表功能。分享给大家供大家参考,具体如下:

先来看看运行效果:

完整代码:



  
    
    www.jb51.net 钟表
    
      body {
background-color:#00A2D4;
      }
      .clock {
 width: 200px;
 height: 200px;
 background: -webkit-radial-gradient(#3b3b3b, #000);
 background: radial-gradient(#2E3F50, #0E1B29);
 box-shadow: inset 0px 0px 30px #131313, 0px 2px 18px rgba(0,0,0,0.5);
 border: 6px solid #172839;
 border-radius: 106px;
 margin: auto;
 position: absolute;
 top: 0; bottom: 0; left: 0; right: 0;
      }
      .hour-hand {
 width: 4px;
 height: 55px;
 background: #fff;
 box-shadow: 0px 0px 7px #000;
 position: absolute;
 top: 45px;
 left: 98px;
      }
      .minute-hand {
 width: 4px;
 height: 80px;
 background: #fff;
 box-shadow: 0px 0px 4px #000;
 position: absolute;
 top: 20px;
 left: 98px;
      }
      .second-hand {
 width: 2px;
 height: 80px;
 background: #bbb;
 box-shadow: 0px 0px 7px #000;
 position: absolute;
 top: 20px;
 left: 99px;
      }
      .pin {
 width: 10px;
 height: 10px;
 background: #222;
 border-radius: 10px;
 margin: auto;
 position: absolute;
 top: 0; bottom: 0; left: 0; right: 0;
      }
      .hour-hand,
      .minute-hand,
      .second-hand {
 -webkit-transform-origin: 50% 100%;
 -moz-transform-origin: 50% 100%;
 -o-transform-origin: 50% 100%;
 -ms-transform-origin: 50% 100%;
 transform-origin: 50% 100%;
      }
      .circle{
 width:20px;
 height:20px;
 line-height:20px;
 text-align:center;
 color:#fff;
 position: absolute;
      }
    
  
  
    
      
      
      
      
      6
      5
      4
      3
      2
      1
      12
      11
      10
      9
      8
      7
    
    
    
  


感兴趣的朋友可使用在线HTML/CSS/Javascript代码运行工具:http://tools.jb51.net/code/HtmlJsRun测试一下运行效果。

PS:这里再为大家推荐几款时间及日期相关工具供大家参考使用:

在线日期/天数计算器:
http://tools.jb51.net/jisuanqi/date_jisuanqi

在线日期计算器/相差天数计算器:
http://tools.jb51.net/jisuanqi/datecalc

在线日期天数差计算器:
http://tools.jb51.net/jisuanqi/onlinedatejsq

Unix时间戳(timestamp)转换工具:
http://tools.jb51.net/code/unixtime

更多关于Javascript相关内容感兴趣的读者可查看本站专题:《Javascript时间与日期操作技巧总结》、《Javascript查找算法技巧总结》、《Javascript错误与调试技巧总结》、《Javascript数据结构与算法技巧总结》、《Javascript遍历算法与技巧总结》及《Javascript数学运算用法总结》

希望本文所述对大家Javascript程序设计有所帮助。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/79554.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号