<!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>time</title>
</head>
<body> <style>
body {
background: black;
} .clock {
position: absolute;
opacity: 1;
} .fill .clock {
left: 50%;
top: 50%;
} .centre {
position: absolute;
top: 50%;
left: 50%;
width: 0;
height: 0;
} .expand {
position: absolute;
top: 0;
left: 0;
transform: translate(-50%, -50%);
} .anchor {
position: absolute;
top: 0;
left: 0;
width: 0;
height: 0;
} .element {
position: absolute;
top: 0;
left: 0;
} .round {
border-radius: 296px;
} .circle-1 {
background: white;
width: 12px;
height: 12px;
} .circle-2 {
background: #FA9F22;
width: 8px;
height: 8px;
} .circle-3 {
background: black;
width: 4px;
height: 4px;
} .second {
transform: rotate(180deg);
} .minute {
transform: rotate(54deg);
} .second-hand {
width: 2px;
height: 164px;
background: #FA9F22;
transform: translate(-50%,-100%) translateY(24px);
} .hour {
transform: rotate(304.5deg);
} .thin-hand {
width: 4px;
height: 50px;
background: white;
transform: translate(-50%,-100%);
} .fat-hand {
width: 10px;
height: 57px;
border-radius: 10px;
background: white;
transform: translate(-50%,-100%) translateY(-18px);
} .minute-hand {
height: 112px;
} .hour-text {
position: absolute;
font: 40px Hei, Helvetica, Arial, sans-serif;
color: white;
transform: translate(-50%,-50%);
} .hour-10 {
padding-left: 0.4ex;
}
.hour-11 {
padding-left: 0.25ex;
} .minute-text {
position: absolute;
font: 12px Avenir Next, Helvetica, Arial, sans-serif;
color: white;
transform: translate(-50%,-50%);
} .minute-line {
background: white;
width: 1px;
height: 9px;
transform: translate(-50%,-100%) translateY(-131px);
opacity: 0.34;
}
</style> <div class="fill">
<div class="reference"></div>
<div class="clock" id="utility-clock" style="transform: scale(1.972);">
<div class="centre">
<div class="dynamic"><div class="anchor" style="transform: rotate(6deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(12deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(18deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(24deg);"><div class="element minute-line"></div></div><div class="minute-text" style="top: -116.9px; left: 67.5px;">05</div><div class="anchor" style="transform: rotate(36deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(42deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(48deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(54deg);"><div class="element minute-line"></div></div><div class="minute-text" style="top: -67.5px; left: 116.9px;">10</div><div class="anchor" style="transform: rotate(66deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(72deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(78deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(84deg);"><div class="element minute-line"></div></div><div class="minute-text" style="top: 0px; left: 135px;">15</div><div class="anchor" style="transform: rotate(96deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(102deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(108deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(114deg);"><div class="element minute-line"></div></div><div class="minute-text" style="top: 67.5px; left: 116.9px;">20</div><div class="anchor" style="transform: rotate(126deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(132deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(138deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(144deg);"><div class="element minute-line"></div></div><div class="minute-text" style="top: 116.9px; left: 67.5px;">25</div><div class="anchor" style="transform: rotate(156deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(162deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(168deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(174deg);"><div class="element minute-line"></div></div><div class="minute-text" style="top: 135px; left: 0px;">30</div><div class="anchor" style="transform: rotate(186deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(192deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(198deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(204deg);"><div class="element minute-line"></div></div><div class="minute-text" style="top: 116.9px; left: -67.5px;">35</div><div class="anchor" style="transform: rotate(216deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(222deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(228deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(234deg);"><div class="element minute-line"></div></div><div class="minute-text" style="top: 67.5px; left: -116.9px;">40</div><div class="anchor" style="transform: rotate(246deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(252deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(258deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(264deg);"><div class="element minute-line"></div></div><div class="minute-text" style="top: 0px; left: -135px;">45</div><div class="anchor" style="transform: rotate(276deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(282deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(288deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(294deg);"><div class="element minute-line"></div></div><div class="minute-text" style="top: -67.5px; left: -116.9px;">50</div><div class="anchor" style="transform: rotate(306deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(312deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(318deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(324deg);"><div class="element minute-line"></div></div><div class="minute-text" style="top: -116.9px; left: -67.5px;">55</div><div class="anchor" style="transform: rotate(336deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(342deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(348deg);"><div class="element minute-line"></div></div><div class="anchor" style="transform: rotate(354deg);"><div class="element minute-line"></div></div><div class="minute-text" style="top: -135px; left: 0px;">60</div><div class="hour-text hour-1" style="top: -90.9px; left: 52.5px;">1</div><div class="hour-text hour-2" style="top: -52.5px; left: 90.9px;">2</div><div class="hour-text hour-3" style="top: 0px; left: 105px;">3</div><div class="hour-text hour-4" style="top: 52.5px; left: 90.9px;">4</div><div class="hour-text hour-5" style="top: 90.9px; left: 52.5px;">5</div><div class="hour-text hour-6" style="top: 105px; left: 0px;">6</div><div class="hour-text hour-7" style="top: 90.9px; left: -52.5px;">7</div><div class="hour-text hour-8" style="top: 52.5px; left: -90.9px;">8</div><div class="hour-text hour-9" style="top: 0px; left: -105px;">9</div><div class="hour-text hour-10" style="top: -52.5px; left: -90.9px;">10</div><div class="hour-text hour-11" style="top: -90.9px; left: -52.5px;">11</div><div class="hour-text hour-12" style="top: -105px; left: 0px;">12</div></div>
<div class="expand round circle-1"></div>
<div class="anchor hour" style="transform: rotate(352.686deg);">
<div class="element thin-hand"></div>
<div class="element fat-hand"></div>
</div>
<div class="anchor minute" style="transform: rotate(4232.24deg);">
<div class="element thin-hand"></div>
<div class="element fat-hand minute-hand"></div>
</div>
<div class="anchor second" style="transform: rotate(253934deg);">
<div class="element second-hand"></div>
</div>
<div class="expand round circle-2"></div>
<div class="expand round circle-3"></div>
</div>
</div>
</div> <script>
var clock = document.querySelector('#utility-clock')
utilityClock(clock) if (clock.parentNode.classList.contains('fill')) autoResize(clock, 295 + 32) function utilityClock(container) {
var dynamic = container.querySelector('.dynamic')
var hourElement = container.querySelector('.hour')
var minuteElement = container.querySelector('.minute')
var secondElement = container.querySelector('.second')
var minute = function(n) {
return n % 5 == 0 ? minuteText(n) : minuteLine(n)
}
var minuteText = function(n) {
var element = document.createElement('div')
element.className = 'minute-text'
element.innerHTML = (n < 10 ? '0' : '') + n
position(element, n / 60, 135)
dynamic.appendChild(element)
}
var minuteLine = function(n) {
var anchor = document.createElement('div')
anchor.className = 'anchor'
var element = document.createElement('div')
element.className = 'element minute-line'
rotate(anchor, n)
anchor.appendChild(element)
dynamic.appendChild(anchor)
}
var hour = function(n) {
var element = document.createElement('div')
element.className = 'hour-text hour-' + n
element.innerHTML = n
position(element, n / 12, 105)
dynamic.appendChild(element)
}
var position = function(element, phase, r) {
var theta = phase * 2 * Math.PI
element.style.top = (-r * Math.cos(theta)).toFixed(1) + 'px'
element.style.left = (r * Math.sin(theta)).toFixed(1) + 'px'
}
var rotate = function(element, second) {
element.style.transform = element.style.webkitTransform = 'rotate(' + (second * 6) + 'deg)'
}
var animate = function() {
var now = new Date()
var time = now.getHours() * 3600 +
now.getMinutes() * 60 +
now.getSeconds() * 1 +
now.getMilliseconds() / 1000
rotate(secondElement, time)
rotate(minuteElement, time / 60)
rotate(hourElement, time / 60 / 12)
requestAnimationFrame(animate)
}
for (var i = 1; i <= 60; i ++) minute(i)
for (var i = 1; i <= 12; i ++) hour(i)
animate()
} function autoResize(element, nativeSize) {
var update = function() {
var scale = Math.min(window.innerWidth, window.innerHeight) / nativeSize
element.style.transform = element.style.webkitTransform = 'scale(' + scale.toFixed(3) + ')'
}
update()
window.addEventListener('resize', update)
}
</script> </body></html>

  

h5 html5 模拟时钟 页面的更多相关文章

  1. HTML5 模拟现实物理效果,感受 Web 技术魅力

    Ball Pool 是一个基于 HTML5 技术的实验,模拟现实物理效果,让你在 Web 中感受自然物体的运动.玩法介绍:可以随意拖动圆球.点击页面背景.晃动浏览器.双击页面背景或者按住鼠标左键,有不 ...

  2. h5之scrollIntoView控制页面元素滚动

    如果滚动页面也是DOM没有解决的一个问题.为了解决这个问题,浏览器实现了一下方法,以方便开发人员如何更好的控制页面的滚动.在各种专有方法中,HTML5选择了scrollIntoView()作为标准方法 ...

  3. 【CSS3】纯CSS代码实现模拟时钟,+js对时功能。

    使用CSS3纯代码来实现模拟时钟,及指针动画功能. 在这里主要使用到css3一些基本元素: border-radius:圆角边框,画圆形:表盘 Transform:变换,旋转,扭曲:刻度盘,指针形状 ...

  4. HTML5中与页面显示相关的API

    1.HTML5中与页面显示相关的API 在HTML5中,增加了几个与页面显示相关的API,其中一个是Page Visibility API Page Visibility API  是指当页面变为最小 ...

  5. 模拟时钟(AnalogClock)和数字时钟(DigitalClock)

    Demo2\clock_demo\src\main\res\layout\activity_main.xml <LinearLayout xmlns:android="http://s ...

  6. JS 模拟手机页面文件的下拉刷新

    js 模拟手机页面文件的下拉刷新初探 老总说需要这个功能,好吧那就看看相关的东西呗 最后弄出了一个简单的下拉刷新页面的形式,还不算太复杂 查看 demo 要在仿真器下才能看到效果,比如chrome的里 ...

  7. 关于html5与jsp页面同样的html代码展示的页面效果不一样的问题

    原文:关于html5与jsp页面同样的html代码展示的页面效果不一样的问题 html5默认的声明为 <!DOCTYPE html> jsp默认的声明头部为 <%@ page con ...

  8. HTML5 增强的页面元素

    一.HTML5 改良的 input 元素的种类 1.<input type="number" id="num1"> var n1 = documen ...

  9. 一个模拟时钟的时间选择器 ClockPicker

    最近开发的一个模拟时钟的时间选择器 ClockPicker,用于 Bootstrap,或者单独作为一个 jQuery 插件. 源代码托管在 GitHub 上: ClockPicker 最近项目中需要用 ...

随机推荐

  1. ADO.NET DataTable的复制(clone)

    using (SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=test;Integrated Se ...

  2. Maven项目下java.lang.ClassNotFoundException常规解决办法

    网上很多要修改.class .project的比较麻烦有时候还不一定管用.下面的方法适合于项目用已经引用了jar,但是运行时却ClassNotFound,请用如下方法试试: 严重: Error con ...

  3. 解决windows搭建jenkins执行selenium无法启动浏览器问题

    因为jenkins是用windows installer 安装成windows的服务了,那么jenkins是一个后台服务,所以跑selium cases 的时候不显示浏览器 Step 1. Contr ...

  4. HDU 6214 Smallest Minimum Cut (最小割且边数最少)

    题意:给定上一个有向图,求 s - t 的最小割且边数最少. 析:设边的容量是w,边数为m,只要把每边打容量变成 w * (m+1) + 1,然后跑一个最大流,最大流%(m+1),就是答案. 代码如下 ...

  5. Java学习总结——常见问题及解决方法

    CYTX项目开发中遇到的问题及解决方法 Android开发各类常见错误解决方案: 使用Android Studio遇到的问题及解决过程 登录注册部分问题及解决: 1.问题:"No targe ...

  6. [label][Apache] VirtualHost

    <VirtualHost *:80>    ServerName   localhost    DocumentRoot "D:\www"</VirtualHos ...

  7. Python学习-6.Python的分支语句

    Python的分支语句比较简单,只有if.else.elif三个关键字,也就是说,Python没有switch语句,而且,Python中并没有?:这个三目运算符. 例子: age = 18 if ag ...

  8. 史上最详细的Hadoop环境搭建(转)

    转载的文章,请告知侵删.本人只是做个记录,以免以后找不到. 前言 Hadoop在大数据技术体系中的地位至关重要,Hadoop是大数据技术的基础,对Hadoop基础知识的掌握的扎实程度,会决定在大数据技 ...

  9. App与微信WebAPP

    我的App与微信搞上了 小麦积分墙摘自网络 最近有很多开发者关心的一个问题是如何提升app的下载量,透过现象开本质,app下载量的终极目标还是为多少客户提供了服务,抛开下载量KPI,app真心关心的问 ...

  10. WebApi 插件式构建方案:发现并加载程序集

    插件式的 WebApi 开发,首要面对的问题就是程序集的发现.因为开发的过程中,都是在各自的解决方案下进行开发,部署后是分模块放在一个整体的的运行时网站下. 约定 这里我根据上一节的设定,把插件打包完 ...