JavaScript實(shí)現(xiàn)動(dòng)態(tài)時(shí)鐘效果
演示
時(shí)間是非常有限的,過(guò)去時(shí)光永遠(yuǎn)不會(huì)再回來(lái)。要在有限的時(shí)間里面,去面對(duì)生活的困難和生存的競(jìng)爭(zhēng),是需要強(qiáng)化自我的。而這些強(qiáng)化學(xué)習(xí)是最需時(shí)間的。而人的精力又是非常有限的,能用來(lái)做有意義的時(shí)間少之又少。所以充分利用好有限的時(shí)間,才能面對(duì)生活的困難和壓力。
配置設(shè)計(jì)
var config={ 'language_type':2, 'font_color':'#dce0f6', 'pointer_color':'#09f5ea', 'sound':0, 'sound_name':'bg.mp3', 'background_style':1, 'background_picture':'bg.jpg', 'background_video':'3.mp4', 'background_color':'#000000', }
旋轉(zhuǎn)功能設(shè)計(jì)
setTimeout(function () { $(".year span").css("animation","yearRun 1s linear infinite"); style.insertRule("@keyframes yearRun {0%{transform: rotateZ(0);transform-origin: -"+yearLeft+" "+top+";}100%{transform:rotateZ(720deg);transform-origin: -"+yearLeft+" "+top+";}}",style.rules.length); $($(".main-content .second span")[0]).removeClass("current"); $(".second span").each(function(index,element){ $(element).css("animation","secondRun"+index+" 1s linear infinite"); style.insertRule("@keyframes secondRun"+index+" {0%{transform: rotateZ(0);transform-origin: -"+secondLeft+" "+top+";}100%{transform:rotateZ("+((index+1)*720)+"deg);transform-origin: -"+secondLeft+" "+top+";}}",style.rules.length); }); $($(".main-content .minute span")[0]).removeClass("current"); $(".minute span").each(function(index,element){ $(element).css("animation","minuteRun"+index+" 1s linear infinite"); style.insertRule("@keyframes minuteRun"+index+" {0%{transform: rotateZ(0);transform-origin: -"+minuteLeft+" "+top+";}100%{transform:rotateZ("+((index+1)*720)+"deg);transform-origin: -"+minuteLeft+" "+top+";}}",style.rules.length); }); $($(".main-content .hour span")[0]).removeClass("current"); $(".hour span").each(function(index,element){ $(element).css("animation","hourRun"+index+" 1s linear infinite"); style.insertRule("@keyframes hourRun"+index+" {0%{transform: rotateZ(0);transform-origin: -"+hourLeft+" "+top+";}100%{transform:rotateZ("+((index+1)*720)+"deg);transform-origin: -"+hourLeft+" "+top+";}}",style.rules.length); }); $($(".main-content .shichen span")[0]).removeClass("current"); $(".shichen span").each(function(index,element){ $(element).css("animation","shichenRun"+index+" 1s linear infinite"); style.insertRule("@keyframes shichenRun"+index+" {0%{transform: rotateZ(0);transform-origin: -"+shichenLeft+" "+top+";}100%{transform:rotateZ("+((index+1)*720)+"deg);transform-origin: -"+shichenLeft+" "+top+";}}",style.rules.length); }); $($(".main-content .week span")[0]).removeClass("current"); $(".week span").each(function(index,element){ $(element).css("animation","weekRun"+index+" 1s linear infinite"); style.insertRule("@keyframes weekRun"+index+" {0%{transform: rotateZ(0);transform-origin: -"+weekLeft+" "+top+";}100%{transform:rotateZ("+((index+1)*720)+"deg);transform-origin: -"+weekLeft+" "+top+";}}",style.rules.length); }); $($(".main-content .day span")[0]).removeClass("current"); $(".day span").each(function(index,element){ $(element).css("animation","dayRun"+index+" 1s linear infinite"); style.insertRule("@keyframes dayRun"+index+" {0%{transform: rotateZ(0);transform-origin: -"+dayLeft+" "+top+";}100%{transform:rotateZ("+((index+1)*720)+"deg);transform-origin: -"+dayLeft+" "+top+";}}",style.rules.length); }); $($(".main-content .month span")[0]).removeClass("current"); $(".month span").each(function(index,element){ $(element).css("animation","monthRun"+index+" 1s linear infinite"); style.insertRule("@keyframes monthRun"+index+" {0%{transform: rotateZ(0);transform-origin: -"+monthLeft+" "+top+";}100%{transform:rotateZ("+((index+1)*720)+"deg);transform-origin: -"+monthLeft+" "+top+";}}",style.rules.length); }); }, 7000);
更新每日
至于每秒每小時(shí)都差不多
$(".day").html(""); Time.days=updateDays(type,year,month,1); Time.currentTime.day=getFirstDay(type); $(".main-content .day").append("<span class='current'>"+Time.currentTime.day+Time.dayUnit+"</span>"); for (const key in Time.days) { if (Time.days.hasOwnProperty(key)) { const element = Time.days[key]; if(element!=Time.currentTime.day){ $(".main-content .day").append("<span>"+element+Time.dayUnit+"</span>"); } } } $(".day span").each(function(index,element){ $(element).css("animation","day"+index+" 0.5s linear"); $(element).css("animation-fill-mode","forwards"); style.insertRule("@keyframes day"+index+"{0%{transform: rotateZ(0);transform-origin: -"+dayLeft+" "+top+";}100%{transform:rotateZ("+-(360/Time.days.length)*(index+1)+"deg);transform-origin: -"+dayLeft+" "+top+";}}",style.rules.length); });
到此這篇關(guān)于JavaScript實(shí)現(xiàn)動(dòng)態(tài)時(shí)鐘效果的文章就介紹到這了,更多相關(guān)js動(dòng)態(tài)時(shí)鐘內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
利用JavaScript實(shí)現(xiàn)3D可旋轉(zhuǎn)粒子矩陣效果
dat.gui.js是一個(gè)一個(gè)輕量級(jí)的圖形用戶(hù)界面庫(kù),或者說(shuō)GUI組件,只有幾十KB,可以用于創(chuàng)建操作控制三維場(chǎng)景的菜單欄等。本文將利用dat.gui.min.js實(shí)現(xiàn)3D可旋轉(zhuǎn)粒子矩陣效果,感興趣的可以了解一下2022-06-06JS簡(jiǎn)單判斷滾動(dòng)條的滾動(dòng)方向?qū)崿F(xiàn)方法
這篇文章主要介紹了JS簡(jiǎn)單判斷滾動(dòng)條的滾動(dòng)方向?qū)崿F(xiàn)方法,涉及javascript針對(duì)scrollTop事件的相關(guān)操作技巧,需要的朋友可以參考下2017-04-04js將多維數(shù)組轉(zhuǎn)為一維數(shù)組后去重排序
本文主要介紹了js將多維數(shù)組轉(zhuǎn)為一維數(shù)組后去重排序,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-06-06JavaScript中的toString()和toLocaleString()方法的區(qū)別
本文給大家介紹JavaScript中的toString()和toLocaleString()方法的區(qū)別,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-02-02詳解html-webpack-plugin插件(用法總結(jié))
這篇文章主要介紹了詳解html-webpack-plugin插件(用法總結(jié)),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-09-09詳解JavaScript中的before-after-hook鉤子函數(shù)
最近看別人的代碼,接觸到一個(gè)插件,before-after-hook,百度搜一圈也沒(méi)有看到什么地方有教程,本文就來(lái)簡(jiǎn)單介紹一下這個(gè)插件的使用方法,需要的可以參考一下2022-12-12