當(dāng)前位置: 首頁(yè) - 軟件下載 - 編程開(kāi)發(fā) - 編程工具 - 抖音時(shí)鐘原生JS文字鐘源碼中文版 v1.0
抖音時(shí)鐘原生JS文字鐘源碼

抖音時(shí)鐘原生JS文字鐘源碼 中文版 v1.0

更新時(shí)間:2019-11-12 支持系統(tǒng):WinALL
軟件大小:22.00KB
軟件分類(lèi): 編程工具
軟件類(lèi)型:國(guó)產(chǎn)軟件
軟件評(píng)級(jí):
軟件授權(quán):免費(fèi)軟件
軟件語(yǔ)言:簡(jiǎn)體中文

      抖音時(shí)鐘原生JS文字鐘源碼中文版是一款相當(dāng)實(shí)用和優(yōu)秀的抖音時(shí)鐘數(shù)字羅盤(pán)源碼,抖音時(shí)鐘原生JS文字鐘源碼中文版抖音時(shí)鐘-通過(guò)原生js實(shí)現(xiàn)抖音很火的一個(gè)文字時(shí)鐘,抖音時(shí)鐘原生JS文字鐘源碼最新版對(duì)于知道干什么的,覺(jué)得設(shè)計(jì)的滿好玩。

截圖

源碼說(shuō)明

      通過(guò)渠道進(jìn)入交流群獲取的,并且附帶另外幾款優(yōu)質(zhì)特效,還有html前端基礎(chǔ)教學(xué)材料,需要的拿走,可以用來(lái)制作引導(dǎo)頁(yè)背景

代碼說(shuō)明

      本文實(shí)例為大家分享了JavaScript實(shí)現(xiàn)抖音羅盤(pán)時(shí)鐘的具體代碼,供大家參考,具體內(nèi)容如下

      其實(shí)很早以前就想發(fā)了,很多東西其實(shí)并不難,只要多動(dòng)手動(dòng)腦就行了,下面直接上代碼,其他的自己下去慢慢研究吧!

      HTML部分代碼:

截圖

      css部分代碼:

截圖

      JavaScript部分代碼:

      var monthText=["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"];

      var dayText=["零一號(hào)","零二號(hào)","零三號(hào)","零四號(hào)","零五號(hào)","零六號(hào)","零七號(hào)","零八號(hào)","零九號(hào)","十號(hào)","十一號(hào)","十二號(hào)","十三號(hào)","十四號(hào)","十五號(hào)","十六號(hào)","十七號(hào)","十八號(hào)","十九號(hào)","二十號(hào)","二十一號(hào)","二十二號(hào)","二十三號(hào)","二十四號(hào)","二十五號(hào)","二十六號(hào)","二十七號(hào)","二十八號(hào)","二十九號(hào)","三十號(hào)","三十一號(hào)"];

      var weekText=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];

      var hourText=["零點(diǎn)","零一點(diǎn)","零兩點(diǎn)","零三點(diǎn)","零四點(diǎn)","零五點(diǎn)","零六點(diǎn)","零七點(diǎn)","零八點(diǎn)","零九點(diǎn)","零十點(diǎn)","十一點(diǎn)","十二點(diǎn)","十三點(diǎn)","十四點(diǎn)","十五點(diǎn)","十六點(diǎn)","十七點(diǎn)","十八點(diǎn)","十九點(diǎn)","二十點(diǎn)","二十一點(diǎn)","二十二點(diǎn)","二十三點(diǎn)"];

      var minuteText=["零一分","零二分","零三分","零四分","零五分","零六分","零七分","零八分","零九分","零十分","十一分","十二分","十三分","十四分","十五分","十六分","十七分","十八分","十九分","二十分","二十一分","二十二分","二十三分","二十四分","二十五分","二十六分","二十七分","二十八分","二十九分","三十分","三十一分","三十二分","三十三分","三十四分","三十五分","三十六分","三十七分","三十八分","三十九分","四十分","四十一分","四十二分","四十三分","四十四分","四十五分","四十六分","四十七分","四十八分","四十九分","五十分","五十一分","五十二分","五十三分","五十四分","五十五分","五十六分","五十七分","五十八分","五十九分","六十分"];

      var secondsText=["零一秒","零二秒","零三秒","零四秒","零五秒","零六秒","零七秒","零八秒","零九秒","零十秒","十一秒","十二秒","十三秒","十四秒","十五秒","十六秒","十七秒","十八秒","十九秒","二十秒","二十一秒","二十二秒","二十三秒","二十四秒","二十五秒","二十六秒","二十七秒","二十八秒","二十九秒","三十秒","三十一秒","三十二秒","三十三秒","三十四秒","三十五秒","三十六秒","三十七秒","三十八秒","三十九秒","四十秒","四十一秒","四十二秒","四十三秒","四十四秒","四十五秒","四十六秒","四十七秒","四十八秒","四十九秒","五十秒","五十一秒","五十二秒","五十三秒","五十四秒","五十五秒","五十六秒","五十七秒","五十八秒","五十九秒","六十秒"];

      var clock;var monthList=[];

      var dayList=[];

      var weekList=[];

      var hourList=[];

      var minuteList=[];

      var secondsList=[];

      var isCircle=false;

      var textSet=[[monthText,monthList],

      [dayText,dayList],

      [weekText,weekList],

      [hourText,hourList],

      [minuteText,minuteList],

      [secondsText,secondsList]];

      window.onload=function()

      {

      init();

      setInterval(function()

      {runTime();

      },100);

      changePosition();

      setTimeout(function()

      {changeCircle();

      },2000);

      }

      function init()

      {clock=document.getElementById('clock');

      for(var i=0;

      i

      {for(var j=0;j

      {var temp=createLabel(textSet[i][0][j]);

      clock.appendChild(temp);textSet[i][1].push(temp);

      }

      }

      }

      function createLabel(text)

      {

      var div=document.createElement('div');

      div.classList.add('label');

      div.innerText=text;return div;

      }

      function runTime()

      {

      var now=new Date();

      var month=now.getMonth();

      var day=now.getDate();

      var week=now.getDay();

      var hour=now.getHours();

      var minute=now.getMinutes();

      var seconds=now.getSeconds();

      initStyle();

      var nowValue=[month,day-1,week,hour,minute,seconds];

      for(var i=0;

      i

      i++)

      {var num=nowValue[i];

      textSet[i][1][num].style.color='#fff';

      }

      if(isCircle)

      {var widthMid=document.body.clientWidth/2;

      var heightMid=document.body.clientHeight/2;

      for(var i=0;

      i

      i++){for(var j=0;

      j

      j++){var r=(i+1)*35+50*i;

      var deg=360/textSet[i][1].length*(j-nowValue[i]);

      var x=r*Math.sin(deg*Math.PI/180)+widthMid;

      var y=heightMid-r*Math.cos(deg*Math.PI/180);

      var temp=textSet[i][1][j];

      temp.style.transform='rotate('+(-90+deg)+'deg)';

      temp.style.left=x+'px';

      temp.style.top=y+'px';

      }

      }

      }

      }

      function initStyle()

      {var label=document.getElementsByClassName('label');

      for(var i=0;

      i

      {label[i].style.color='#4d4d4d';

      }

      }

      function changePosition()

      {

      for(let i=0;i

      i++)

      {

      for(let j=0;

      j

      j++){

      let tempX=textSet[i][1][j].offsetLeft+"px";

      let tempY=textSet[i][1][j].offsetTop+"px";

      setTimeout(function(){

      textSet[i][1][j].style.position="absolute";

      textSet[i][1][j].style.left=tempX;textSet[i][1][j].style.top=tempY;

      },50);

      }

      }

      }

      function changeCircle()

      {

      isCircle=true;

      clock.style.transform="rotate(90deg)";

      }

下載地址

安全下載地址

優(yōu)先使用Windsoul軟件管家下載,更安全高效

電信安全下載 聯(lián)通安全下載 移動(dòng)安全下載 網(wǎng)通安全下載

抖音時(shí)鐘原生JS文字鐘源碼