HTML罗盘式时钟的实现
代码块:
<!DOCTYPE html>
<html lang="zh-hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>js仿抖罗盘时钟</title>
<style>
*{
margin:0;
padding:0
}
html,body{
width:100%;
height:100%;
background-color:#000;
overflow:hidden
}
#clock{
position:relative;
width:100%;
height:100%;
background:#000
}
.label{
display:inline-block;
color:#4d4d4d;
text-align:center;
padding:0 5px;
font-size:19px;
transition:left 1s,top 1s;
transform-origin:0% 0%
}
</style>
</head>
<body>
<div id="clock"></div>
<script>
var monthText=["⼀⽉","⼆⽉","三⽉","四⽉","五⽉","六⽉","七⽉","⼋⽉","九⽉","⼗⽉","⼗⼀⽉","⼗⼆⽉"];
var dayText=["零⼀号","零⼆号","零三号","零四号","零五号","零六号","零七号","零⼋号","零九号","⼗号","⼗⼀号","⼗⼆号","⼗三号","⼗四号","⼗五号","⼗六号","⼗七号","⼗⼋号","⼗九号","⼆⼗号","⼆⼗⼀号","⼆⼗⼆号","⼆⼗三号","⼆⼗四号","⼆⼗五号              var weekText=["星期⽇","星期⼀","星期⼆","星期三","星期四","星期五","星期六"];
var hourText=["零点","零⼀点","零两点","零三点","零四点","零五点","零六点","零七点","零⼋点","零九点","零⼗点","⼗⼀点","⼗⼆点","⼗三点","⼗四点","⼗五点","⼗六点","⼗七点","⼗⼋点","⼗九点","⼆⼗点","⼆⼗⼀点","⼆⼗⼆点","⼆⼗三点"];
var minuteText=["零⼀分","零⼆分","零三分","零四分","零五分","零六分","零七分","零⼋分","零九分","零⼗分","⼗⼀分","⼗⼆分","⼗三分","⼗四分","⼗五分","⼗六分","⼗七分","⼗⼋分","⼗九分","⼆⼗分","⼆⼗⼀分","⼆⼗⼆分","⼆⼗三分","⼆⼗四分","⼆⼗              var secondsText=["零⼀秒","零⼆秒","零三秒","零四秒","零五秒","零六秒","零七秒","零⼋秒","零九秒","零⼗秒","⼗⼀秒","⼗⼆秒","⼗三秒","⼗四秒","⼗五秒","⼗六秒","⼗七秒","⼗⼋秒","⼗九秒","⼆⼗秒","⼆⼗⼀秒","⼆⼗⼆秒","⼆⼗三秒","⼆⼗四秒","⼆              var clock;var monthList=[];
var dayList=[];
var weekList=[];
var hourList=[];
var minuteList=[];
html特效代码天气时钟
var secondsList=[];
var isCircle=false;
var textSet=[[monthText,monthList],[dayText,dayList],[weekText,weekList],[hourText,hourList],[minuteText,minuteList],[secondsText,secondsList]];
init();
setInterval(function(){
runTime();
},100);
changePosition();
setTimeout(function(){
changeCircle();
},2000);
}
function init(){
ElementById('clock');
for(var i=0;i<textSet.length;i++){
for(var j=0;j<textSet[i][0].length;j++){
var temp=createLabel(textSet[i][0][j]);
clock.appendChild(temp);textSet[i][1].push(temp);
}
}
}
function createLabel(text)
{
var ateElement('div');
div.classList.add('label');
div.innerText=text;return div;
}
function runTime(){
var now=new Date();
var Month();
var Date();
var Day();
var Hours();
var Minutes();
var Seconds();
initStyle();
var nowValue=[month,day-1,week,hour,minute,seconds];
for(var i=0;i<nowValue.length;i++){
var num=nowValue[i];
textSet[i][1][num].lor='#fff';
}
if(isCircle){
var widthMid=document.body.clientWidth/2;
var heightMid=document.body.clientHeight/2;
for(var i=0;i<textSet.length;i++){
for(var j=0;j<textSet[i][0].length;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=s(deg*Math.PI/180);
var temp=textSet[i][1][j];
ansform='rotate('+(-90+deg)+'deg)';
temp.style.left=x+'px';
p=y+'px';
}
}
}
}
function initStyle(){
var ElementsByClassName('label');
for(var i=0;i<label.length;i++){
label[i].lor='#4d4d4d';
}
}
function changePosition(){
for(let i=;i<textSet.length;i++){
for(let j=0;j<textSet[i][1].length;j++){
let tempX=textSet[i][1][j].offsetLeft+"px";
let tempY=textSet[i][1][j].offsetTop+"px";
setTimeout(function(){
textSet[i][][j].style.position="absolute";
textSet[i][1][j].style.left=tempX;textSet[i][1][j].p=tempY;
},50);
}
}
}
function changeCircle(){
isCircle=true;
ansform="rotate(90deg)";
}
</script>
</body>
</html>
效果:
到此这篇关于HTML 罗盘式时钟的实现的⽂章就介绍到这了,更多相关HTML 罗盘式时钟内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章,希望⼤家以后多多⽀持!

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。