Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
html, body { width: 100%; height: 100%; padding: 0; margin: 0; } body { background-color: #00d771; display: flex; align-items: center; justify-content: center; } .clock { background-color: #ffffff; width: 70vw; height: 70vw; max-width: 70vh; max-height: 70vh; border: solid 2.8vw #242424; position: relative; overflow: hidden; border-radius: 50%; box-sizing: border-box; box-shadow: 0 1.4vw 2.8vw rgba(0, 0, 0, 0.8); } .memory { position: absolute; top: 50%; left: 50%; transform-origin: center; } .memory:nth-child(1) { background-color: #424242; width: 2%; height: 8%; transform: translate(-50%, -50%) rotate(0deg) translateY(-520%); } .memory:nth-child(2) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(6deg) translateY(-1461%); } .memory:nth-child(3) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(12deg) translateY(-1461%); } .memory:nth-child(4) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(18deg) translateY(-1461%); } .memory:nth-child(5) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(24deg) translateY(-1461%); } .memory:nth-child(6) { background-color: #424242; width: 2%; height: 8%; transform: translate(-50%, -50%) rotate(30deg) translateY(-520%); } .memory:nth-child(7) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(36deg) translateY(-1461%); } .memory:nth-child(8) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(42deg) translateY(-1461%); } .memory:nth-child(9) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(48deg) translateY(-1461%); } .memory:nth-child(10) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(54deg) translateY(-1461%); } .memory:nth-child(11) { background-color: #424242; width: 2%; height: 8%; transform: translate(-50%, -50%) rotate(60deg) translateY(-520%); } .memory:nth-child(12) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(66deg) translateY(-1461%); } .memory:nth-child(13) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(72deg) translateY(-1461%); } .memory:nth-child(14) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(78deg) translateY(-1461%); } .memory:nth-child(15) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(84deg) translateY(-1461%); } .memory:nth-child(16) { background-color: #424242; width: 2%; height: 8%; transform: translate(-50%, -50%) rotate(90deg) translateY(-520%); } .memory:nth-child(17) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(96deg) translateY(-1461%); } .memory:nth-child(18) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(102deg) translateY(-1461%); } .memory:nth-child(19) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(108deg) translateY(-1461%); } .memory:nth-child(20) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(114deg) translateY(-1461%); } .memory:nth-child(21) { background-color: #424242; width: 2%; height: 8%; transform: translate(-50%, -50%) rotate(120deg) translateY(-520%); } .memory:nth-child(22) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(126deg) translateY(-1461%); } .memory:nth-child(23) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(132deg) translateY(-1461%); } .memory:nth-child(24) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(138deg) translateY(-1461%); } .memory:nth-child(25) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(144deg) translateY(-1461%); } .memory:nth-child(26) { background-color: #424242; width: 2%; height: 8%; transform: translate(-50%, -50%) rotate(150deg) translateY(-520%); } .memory:nth-child(27) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(156deg) translateY(-1461%); } .memory:nth-child(28) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(162deg) translateY(-1461%); } .memory:nth-child(29) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(168deg) translateY(-1461%); } .memory:nth-child(30) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(174deg) translateY(-1461%); } .memory:nth-child(31) { background-color: #424242; width: 2%; height: 8%; transform: translate(-50%, -50%) rotate(180deg) translateY(-520%); } .memory:nth-child(32) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(186deg) translateY(-1461%); } .memory:nth-child(33) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(192deg) translateY(-1461%); } .memory:nth-child(34) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(198deg) translateY(-1461%); } .memory:nth-child(35) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(204deg) translateY(-1461%); } .memory:nth-child(36) { background-color: #424242; width: 2%; height: 8%; transform: translate(-50%, -50%) rotate(210deg) translateY(-520%); } .memory:nth-child(37) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(216deg) translateY(-1461%); } .memory:nth-child(38) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(222deg) translateY(-1461%); } .memory:nth-child(39) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(228deg) translateY(-1461%); } .memory:nth-child(40) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(234deg) translateY(-1461%); } .memory:nth-child(41) { background-color: #424242; width: 2%; height: 8%; transform: translate(-50%, -50%) rotate(240deg) translateY(-520%); } .memory:nth-child(42) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(246deg) translateY(-1461%); } .memory:nth-child(43) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(252deg) translateY(-1461%); } .memory:nth-child(44) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(258deg) translateY(-1461%); } .memory:nth-child(45) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(264deg) translateY(-1461%); } .memory:nth-child(46) { background-color: #424242; width: 2%; height: 8%; transform: translate(-50%, -50%) rotate(270deg) translateY(-520%); } .memory:nth-child(47) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(276deg) translateY(-1461%); } .memory:nth-child(48) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(282deg) translateY(-1461%); } .memory:nth-child(49) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(288deg) translateY(-1461%); } .memory:nth-child(50) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(294deg) translateY(-1461%); } .memory:nth-child(51) { background-color: #424242; width: 2%; height: 8%; transform: translate(-50%, -50%) rotate(300deg) translateY(-520%); } .memory:nth-child(52) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(306deg) translateY(-1461%); } .memory:nth-child(53) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(312deg) translateY(-1461%); } .memory:nth-child(54) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(318deg) translateY(-1461%); } .memory:nth-child(55) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(324deg) translateY(-1461%); } .memory:nth-child(56) { background-color: #424242; width: 2%; height: 8%; transform: translate(-50%, -50%) rotate(330deg) translateY(-520%); } .memory:nth-child(57) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(336deg) translateY(-1461%); } .memory:nth-child(58) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(342deg) translateY(-1461%); } .memory:nth-child(59) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(348deg) translateY(-1461%); } .memory:nth-child(60) { background-color: #949494; width: 1%; height: 3%; transform: translate(-50%, -50%) rotate(354deg) translateY(-1461%); } .needle { position: absolute; top: 50%; left: 50%; transform-origin: center; } .needle#hours { background-color: #1f1f1f; width: 4%; height: 30%; transform-origin: center 75%; transform: translate(-50%, -75%); } .needle#hours.moving { transition: transform 150ms ease-out; } .needle#hours:after { content: ''; background-color: #1f1f1f; width: 4vw; height: 4vw; max-width: 4vh; max-height: 4vh; display: block; position: absolute; top: 75%; left: 50%; box-sizing: border-box; border-radius: 50%; transform: translate(-50%, -50%); } .needle#minutes { background-color: #1f1f1f; width: 2%; height: 45%; transform-origin: center 75%; transform: translate(-50%, -75%); } .needle#minutes.moving { transition: transform 150ms ease-out; } .needle#minutes:after { content: ''; background-color: #1f1f1f; width: 4vw; height: 4vw; max-width: 4vh; max-height: 4vh; display: block; position: absolute; top: 75%; left: 50%; box-sizing: border-box; border-radius: 50%; transform: translate(-50%, -50%); } .needle#seconds { background-color: #cb2f2f; width: 1%; height: 50%; transform-origin: center 75%; transform: translate(-50%, -75%); } .needle#seconds.moving { transition: transform 150ms ease-out; } .needle#seconds:after { content: ''; background-color: #cb2f2f; width: 2.5vw; height: 2.5vw; max-width: 2.5vh; max-height: 2.5vh; display: block; position: absolute; top: 75%; left: 50%; box-sizing: border-box; border-radius: 50%; transform: translate(-50%, -50%); } @media (min-width: 100vh) { .clock { border: solid 2.8vh #242424; box-shadow: 0 1.4vh 2.8vh rgba(0, 0, 0, 0.8); } }
JavaScript
// ----- Variable declaration var data = { dt: new Date(), hours: { el: document.querySelector('#hours'), val: 0 }, minutes: { el: document.querySelector('#minutes'), val: 0 }, seconds: { el: document.querySelector('#seconds'), val: 0 }, renderTime: 1000 }; // ----- Clock rendering logic updateTime = () => { let hour = data.dt.getHours(); let minute = data.dt.getMinutes(); let second = data.dt.getSeconds(); data.hours.el.classList.add('moving'); data.minutes.el.classList.add('moving'); data.seconds.el.classList.add('moving'); data.hours.val = (hour == 0 && data.hours.val == 59 * 6 * 5) ? 360 : (hour * 6 * 5); data.minutes.val = (minute == 0 && data.minutes.val == 59 * 6) ? 360 : (minute * 6); data.seconds.val = (second == 0 && data.seconds.val == 59 * 6) ? 360 : (second * 6); data.hours.el.style.transform = `translate(-50%, -75%) rotate(${data.hours.val}deg)`; data.minutes.el.style.transform = `translate(-50%, -75%) rotate(${data.minutes.val}deg)`; data.seconds.el.style.transform = `translate(-50%, -75%) rotate(${data.seconds.val}deg)`; data.dt.setSeconds(second + 1); } // ----- Clock execution setInterval(() => { updateTime(); }, data.renderTime); updateTime(); // ----- Events area data.seconds.el.addEventListener('transitionend', () => { data.hours.el.classList.remove('moving'); data.minutes.el.classList.remove('moving'); data.seconds.el.classList.remove('moving'); if (data.hours.val == 360) { data.hours.el.style.transform = 'translate(-50%, -75%) rotate(0deg)'; } if (data.minutes.val == 360) { data.minutes.el.style.transform = 'translate(-50%, -75%) rotate(0deg)'; } if (data.seconds.val == 360) { data.seconds.el.style.transform = 'translate(-50%, -75%) rotate(0deg)'; } });
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>模拟时钟-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号