CSS3 and js simple digital clock code
<script> 'use strict'; var size = 86; var columns = Array.from(document.getElementsByClassName('column')); var d = undefined, c = undefined; var classList = ['visible', 'close', 'far', 'far', 'distant', 'distant']; var use24HourClock = true; function padClock(p, n) { return p + ('0' + n).slice(-2); } function getClock() { d = new Date(); return [use24HourClock ? d.getHours() : d.getHours() % 12 || 12, d.getMinutes(), d.getSeconds()].reduce(padClock, ''); } function getClass(n, i2) { return classList.find(function (class_, classIndex) { return i2 - classIndex === n || i2 + classIndex === n; }) || ''; } var loop = setInterval(function () { c = getClock(); columns.forEach(function (ele, i) { var n = +c[i]; var offset = -n * size; ele.style.transform = 'translateY(calc(50vh + ' + offset + 'px - ' + size / 2 + 'px))'; Array.from(ele.children).forEach(function (ele2, i2) { ele2.className = 'num ' + getClass(n, i2); }); }); }, 200 + Math.E * 10); </script>
这是一款简单的自动获取本地时间的css3+js简单数字时钟代码,时分秒上下滚动动画切换网页时钟特效。
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
16 May 2016
Digital clocks are used in web countdown, web alarm clock effects and web apps based on HTML5. This article introduces to you how to make a digital clock based on jquery and css3 with source code download. Interested friends can take a look.
20 Sep 2018
This chapter introduces how to use css3 and js to achieve dynamic clock effects. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
22 Jun 2018
This article mainly introduces the code for making clocks using Css3 and Js. It has certain reference value. Now I share it with you. Friends in need can refer to it.
09 Sep 2023
How to skillfully use CSS3 special effects to improve the user experience of web pages. With the development of the Internet, web design and user experience have become important links in website development. The application of CSS3 special effects can add dynamics and visual effects to web pages and improve user experience. This article will introduce several common CSS3 special effects and their code examples to help developers become more proficient in using CSS3 special effects and improve the user experience of web pages. Transition effect (Transition) Transition effect is one of the most basic special effects in CSS3. By changing a certain attribute
20 Sep 2018
What this article brings to you is about the process of using css3 and js to implement a clock code. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
22 Mar 2018
This time I will bring you the implementation of CSS3 visual special effects. What are the precautions for realizing CSS3 visual special effects? The following is a practical case, let’s take a look.
14 Sep 2017
Using HTML5 and CSS to achieve the pendulum effect is often encountered in projects. Today I will share the implementation code of a simple clock effect based on HTML5+CSS3 on the platform. Friends who need it can refer to it.
11 Jul 2018
This article mainly introduces how to use JS to implement a simple digital clock. It has certain reference value. Now I share it with you. Friends in need can refer to it.
16 May 2016
jQuery and CSS3 are definitely used a lot for web front-end development. Next, I will share some special effects made by jQuery and CSS3. I hope it will be helpful to friends who like to learn special effects.
Hot Tools
CSS text is combined into a heart-shaped animation special effect
CSS text is combined into a heart-shaped animation special effect
CSS3 SVG expression flower animation special effects
SS3 SVG confession flower animation special effect is a Valentine's Day animation special effect.
CSS shopping mall websites commonly use left category drop-down navigation menu code
CSS shopping mall websites commonly use left category drop-down navigation menu code
jQuery+CSS3 Valentine's Day love special effects
jQuery+CSS3 Valentine's Day Love Special Effect is a Valentine's Day hanging swinging heart animation special effect.
css3 spoon scooping up glutinous rice balls animation special effects
A bowl of cute glutinous rice balls expression, a spoon scooping up a glutinous rice balls animation special effects