前端DEMO:网络上流行的抖音罗盘

一、效果:

二、关于代码:

CSS/demo.css代码:

* {margin: 0;padding: 0;
}
html,
body {width: 100%;height: 100%;background-color: black;overflow: hidden;
}
#clock {position: relative;width: 100%;height: 100%;background: black;
}
.label {display: inline-block;color: #4d4d4d;text-align: center;padding: 0 5px;font-size: 16px;transition: left 1s, top 1s;transform-origin: 0% 0%;
}

JS/demo.js代码:

var monthText = ["壹月","贰月","叁月","肆月","伍月","陆月","柒月","捌月","玖月","拾月","拾壹月","拾贰月",
];
var dayText = ["壹号","贰号","叁号","肆号","伍号","陆号","柒号","捌号","玖号","拾号","拾壹号","拾贰号","拾叁号","拾肆号","拾伍号","拾陆号","拾柒号","拾捌号","拾玖号","贰拾号","贰拾壹号","贰拾贰号","贰拾叁号","贰拾肆号","贰拾伍号","贰拾陆号","贰拾柒号","贰拾捌号","贰拾玖号","叁拾号","叁拾壹号",
];
var weekText = ["星期日","星期壹","星期贰","星期叁","星期肆","星期伍","星期陆",
];
var hourText = ["零点","壹点","贰点","叁点","肆点","伍点","陆点","柒点","捌点","玖点","拾点","拾壹点","拾贰点","拾叁点","拾肆点","拾伍点","拾陆点","拾柒点","拾捌点","拾玖点","贰拾点","贰拾壹点","贰拾贰点","贰拾叁点",
];
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 < 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 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 < nowValue.length; i++) {var num = nowValue[i];textSet[i][1][num].style.color = "red";}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 = 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.length; i++) {label[i].style.color = "white";}
}
function changePosition() {for (let i = 0; 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][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)";
}

index.html代码:

<!doctype html>
<html lang="en"><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"><link rel="stylesheet" href="css/demo.css">
</head><body><div id="clock"></div><script src="js/demo.js"></script>
</body></html>

三、源码完整版地址:

https://github.com/CuiYanchang-Github/Html-Example/tree/master/%E6%8A%96%E9%9F%B3%E7%BD%97%E7%9B%98

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/473160.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

一个符合SEO优化标准的网站应具备哪些特征?

我们在进行网站建设时&#xff0c;都希望自己的网站能在搜索引擎中获得一个好的排名&#xff0c;都希望自己的网站能有很多的网页被百度等主流搜索引擎收录。要想获得搜索引擎的青睐&#xff0c;前提是要做好网站的SEO优化。那么&#xff0c;一个符合SEO优化标准的网站应该具备…

[Kaggle] Sentiment Analysis on Movie Reviews(BERT)

文章目录1. 预训练模型下载2. 数据集3. 加载预训练模型4. 提交结果练习地址&#xff1a;https://www.kaggle.com/c/sentiment-analysis-on-movie-reviews 相关博文&#xff1a; [Kaggle] Spam/Ham Email Classification 垃圾邮件分类&#xff08;BERT&#xff09; 本文使用 hu…

Qt利用avilib实现录屏功能_openlayers6结合geoserver利用WFS服务实现图层编辑功能(附源码下载)...

内容概览1.openlayers6结合geoserver利用WFS服务实现图层编辑功能2.源代码demo下载效果图如下&#xff1a;本篇主要是参照openlayers6结合geoserver利用WFS服务实现图层新增功能(附源码下载)基础上实现的&#xff0c;openlayers6通过调用geoserver发布的地图服务WFS来达到图层编…

Python 解决写入csv中间隔一行空行问题

一、问题描述&#xff1a;生成的csv文件每两行中间都有一行空白行 # 写入csv&#xff1a; with open(birth_weight_file,w) as f:writercsv.writer(f)writer.writerow(birth_header)writer.writerows(birth_data)f.close() 二、解决办法&#xff1a;写入后面加上newline wit…

LeetCode DD-2020006. 简单游戏(前缀和)

文章目录1. 题目2. 解题1. 题目 给出一个长度为 n 的数组 a&#xff0c;你需要在这个数组中找到一个长度至少为 m 的区间&#xff0c;使得这个区间内的数字的和尽可能小。 输入描述: 第一行包含一个正整数 n&#xff0c;m,表示数组的大小和所选区间的最小长度。(1<n<1…

【转载】OpenStack Swift学习笔记

免责声明&#xff1a; 本文转自网络文章&#xff0c;转载此文章仅为个人收藏&#xff0c;分享知识&#xff0c;如有侵权&#xff0c;请联系博主进行删除。 原文作者&#xff1a;崔炳华 原文地址&#xff1a;http://blog.csdn.net/i_chips/article/details/17787017 1 概…

Android Studio 选项菜单和动画结合_Android 应用与iOS 应用之间的设计差异对比!

同一个App&#xff0c;为什么iOS 和Android 的交互操作有那么大的区别&#xff1f;本文将用大量原生设计案例&#xff0c;为你一一说明它们为什么应该这样做&#xff0c;赶紧学起来&#xff01;了解并适当结合平台规范与优势&#xff0c;才能做到最佳的用户体验。为了创建最佳的…

图片操作案例:python 批量更改图像尺寸到统一大小的方法

一、需求&#xff1a; 批量修改该图片长与宽尺寸 二、素材&#xff1a; 三、代码&#xff1a; from PIL import Image import os.path import globdef convertjpg(jpgfile,outdir,width512,height512):imgImage.open(jpgfile)try:new_imgimg.resize((width,height),Image.BI…

LeetCode 753. 破解保险箱(DFS)

文章目录1. 题目2. 解题1. 题目 有一个需要密码才能打开的保险箱。 密码是 n 位数, 密码的每一位是 k 位序列 0, 1, …, k-1 中的一个 。 你可以随意输入密码&#xff0c;保险箱会自动记住最后 n 位输入&#xff0c;如果匹配&#xff0c;则能够打开保险箱。 举个例子&#x…

windows副本不是正版怎么解决_解决Windows沙盒怎么联网问题

windows 沙盒简单来讲就是一款沙盒虚拟化的Windows系统&#xff0c;而最近还蛮多小伙伴来问小编说&#xff0c;Windows沙盒能够联网吗&#xff1f;Windows沙盒怎么联网&#xff1f;针对这个问题&#xff0c;接下来小编就来和大家好好的说说关于windows沙盒的情况吧。1、首先我们…

textract安装使用

http://textract.readthedocs.org/en/latest/ import textracttext textract.process("rbm.pdf")转载于:https://www.cnblogs.com/huiwq1990/p/3915751.html

西瓜视频(头条)解析并利用IDM工具下载

一、西瓜视频网址解析完整代码&#xff1a; import requests import urllib3 urllib3.disable_warnings() import re import json import base64cookie你的cookie headers{"user-agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like…

天池 在线编程 寻找字母(计数)

文章目录1. 题目2. 解题1. 题目 给定一个字符串str&#xff0c;返回字符串中字母顺序最大的而且同时在字符串中出现大写和小写的字母。 如果不存在这样的字母&#xff0c;返回‘~‘。 please return uppercase |str|<1000示例 例 1&#xff1a; 输入:"aAbBcD" 输…

电脑硬件检测_【学无止境】电脑硬件维修测试学习资料(附送各类PC检修资源)...

大橙子资源驿站『 电脑硬件维修测试学习资料』多年的PC硬件检修工具和资料&#xff0c;都是本人一年年亲测积累起来的&#xff0c;安全无毒。打包上传分享给大家。—— 资源分享者语关于『 电脑硬件维修学习资料 』这是甛橙从论坛搬运的&#xff0c;因为看着评分挺高&#xff0…

加速国内 Github 访问,下载的9种方案!

1、GitHub 镜像访问 ​​​​​​​这里提供两个最常用的镜像地址&#xff1a; https://github.com.cnpmjs.org https://hub.fastgit.org 也就是说上面的镜像就是一个克隆版的Github&#xff0c;你可以访问上面的镜像网站&#xff0c;网站的内容跟Github是完整同步的镜像&…

C#验证邮件

public static bool IsEmail(string email) {String strExp "\w([-.]\w)*\w([-.]\w)*\.\w([-.]\w)*";Regex r new Regex(strExp);Match m r.Match(email);return m.Success; }转载于:https://www.cnblogs.com/51net/p/3916075.html

天池 在线编程 三等分(模拟)

文章目录1. 题目2. 解题1. 题目 给定一个由 0 和 1 组成的数组 A&#xff0c;将数组分成 3 个非空的部分&#xff0c;使得所有这些部分表示相同的二进制值。 如果可以做到&#xff0c;请返回任何 [i, j]&#xff0c;其中 i1 < j&#xff0c;这样一来&#xff1a; A[0], A…

Python设计模式之模板方法模式实例详解

1、模板方法模式定义 定义一个操作中的算法的框架&#xff0c;而将一些步骤延迟到子类中&#xff0c;使得子类可以不改变一个算法的结构即可重新定义该算法的某些特定的步骤。 子类实现的具体方法叫作基本方法&#xff0c;实现对基本方法高度的框架方法&#xff0c;叫作模板方…

小米2s自带rec刷root_刷Magisk模块开机卡Logo了怎么办?两种方法教你轻松解决

虽然&#xff0c;Magisk由于工作原理的不同&#xff0c;其模块对系统的兼容性相比较于此前的Xposed框架模块要好得多&#xff0c;但是依旧有可能出现刷了模块之后&#xff0c;卡Logo&#xff0c;无法开机的情况。今天&#xff0c;小编就提供两种方式解决刷Magisk模块卡开机Logo…

设计模式——简单工厂

设计模式——简单工厂 工厂角色&#xff1a; package designpattern.creation.simplefactory;/** * 此处的工厂简单写成一个类&#xff0c;因为&#xff08;简单工厂的工厂&#xff09;不会有继承或拓展&#xff0c;可以不用写成接口。*/ public class Factory {public IProduc…