canvas数字时钟显示时间效果代码
代码语言:html
所属分类:其他
代码描述:canvas数字时钟显示时间效果代码,秒针走动设计以多层其那套圆环走动显示。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> html, body { background: #204; font-family: sans-serif; } #clock { width: 700px; height: 700px; position: relative; margin: 70px auto 0px; } #clockTime { color: rgba(255,255,255,0.7); font-size: 120px; text-align: center; font-weight: 900; position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; } </style> </head> <body > <div id="clock"></div> <script > function Clock(){ this.centerXY = 350; this.CtxSize = 700; this.time = ''; this.init = function() { document.getElementById('clock').innerHTML = ` <canvas id="clockCanvas"></canvas> <div id="clockTime">Juhu</div> `; this.timeDiv = document.getElementById('clockTime'); this.timeCanvas = document.getElementById('clockCanvas'); this.Ctx = this.timeCanvas.getContext('2d'); this.timeCanvas.width = this.CtxSize; this.timeCanvas.height = this.CtxSize; this.tick(); } this.tick = function() { this.now = new Date(); this.S = parseInt(this.now.........完整代码请登录后点击上方下载按钮下载查看
网友评论0