div+js实现划线计数式时分秒显示当前时间代码
代码语言:html
所属分类:布局界面
代码描述:div+js实现划线计数式时分秒显示当前时间代码
代码标签: div js 划线 计数式 时分秒 显示 当前 时间 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Indie+Flower&display=swap'>
<style>
* {
border: 0;
box-sizing: border-box;
margin: 0;
padding: 0;
}
:root {
--hue: 223;
--fg: hsl(var(--hue),10%,90%);
--trans-dur: 0.3s;
font-size: calc(16px + (32 - 16) * (100vw - 320px) / (2560 - 320));
}
body {
background: url(//repo.bfw.wiki/bfwrepo/image/64328730b3a12.png) center / 18em auto;
color: var(--fg);
display: flex;
font: 1em/1.5 "Indie Flower", cursive;
height: 100vh;
min-height: 480px;
}
.clock {
display: block;
margin: auto;
width: 16em;
height: auto;
}
.clock__digit-stroke {
stroke-dasharray: 16 16;
stroke-dashoffset: 16;
transition: stroke-dashoffset var(--trans-dur) cubic-bezier(0.65,0,0.35,1);
}
.clock__digit-stroke:last-child {
stroke-dasharray: 21 21;
stroke-dashoffset: 21;
}
[data-strokes="1"] .clock__digit-stroke:nth-child(-n + 1),
[data-strokes="2"] .clock__digit-stroke:nth-child(-n + 2),
[data-strokes="3"] .clock__digit-stroke:nth-child(-n + 3),
[data-strokes="4"] .clock__digit-stroke:nth-child(-n + 4),
[data-strokes="5"] .clock__digit-stroke:nth-child(-n + 5) {
stroke-dashoffset: 0;
}
[data-strokes="0"] .clock__digit-stroke {
transition-duration: 0.1s;
transition-timing-function: linear;
}
[data-strokes="0"]:nth-child(1) .clock__digit-stroke,
[data-strokes="0"]:nth-child(2) .clock__digit-stroke {
transition-delay: 0.5s;
}
[data-strokes="0"]:nth-child(3) .clock__digit-stroke,
[data-strokes="0"]:nth-child(4) .clock__digit-stroke {
transition-delay: 0.4s;
}
[data-strokes="0"]:nth-child(5) .clock__digit-stroke,
[data-strokes="0"]:nth-child(6) .clock__digit-stroke {
transition-delay: 0.3s;
}
[data-strokes="0"]:nth-child(7) .clock__digit-stroke,
[data-strokes="0"]:nth-child(8) .clock__digit-stroke {
transition-delay: 0.2s;
}
[data-strokes="0"]:nth-child(9) .clock__digit-stroke,
[data-strokes="0"]:nth-child(10) .clock__digit-stroke {
transition-delay: 0.1s;
}
</style>
</head>
<body>
<svg class="clock" viewBox="0 0 140 140" width="140px" height="140px" role="img">
<g fill="currentcolor" font-size="12" transform="translate(0,14)">
<text x="20" text-anchor="middle">Hour</text>
<text x="70" text-anchor="middle">Minute</text>
<text x="120" text-anchor="middle">Second</text>
</g>
<g stroke="currentcolor" stroke-width="2" stroke-linecap="round">
<polyline points="45 2,45 138" />
<polyline points="95 2,95 138" />
</g>
<g stroke="currentcolor" stroke-width="2" stroke-linecap="round" transform="translate(0,20)">
<g class="clock__column" data-column="h">
<g class="clock__digit-strokes" data-strokes="0" transform="translate(2,2)">
<polyline class="clock__digit-stroke" points="2 0,2 16" />
<polyline class="clock__digit-stroke" points="6 0,6 16" />
<polyline class="clock__digit-stroke" points="10 0,10 16" />
<polyline class="clock__digit-stroke" points="14 0,14 16" />
<polyline class="clock__digit-stroke" points="0 2,16 14" />
</g>
<g class="clock__digit-strokes" data-strokes="0" transform="translate(22,2)">
<polyline class="clock__digit-stroke" points="2 0,2 16" />
<polyline class="clock__digit-stroke" points="6 0,6 16" />
<polyline class="clock__digit-stroke" points="10 0,10 16" />
<polyline class="clock__digit-stroke" points="14 0,14 16" />
<polyline class="clock__digit-stroke" points="0 2,16 14" />
</g>
<g class="clock__digit-strokes" data-strokes="0" transform="translate(2,22)">
<polyline class="clock__digit-stroke" points="2 0,2 16" />
<polyline class="clock__digit-stroke" points="6 0,6 16" />
<polyline class="clock__digit-stroke" points="10 0,10 16" />
<polyline class="clock__digit-stroke" points="14 0,14 16" />
<polyline class="clock__digit-stroke" points="0 2,16 14" />
</g>
<g class="clock__digit-strokes" data-strokes="0" transform="translate(22,22)">
<polyline class="clock__digit-stroke" points="2 0,2 16" />
<polyline class="clock__digit-stroke" points="6 0,6 16" />
<polyline class="clock__digit-stroke" points="10 0,10 16" />
<polyline class="clock__digit-stroke" points="14 0,14 16" />
<polyline class="clock__digit-stroke" points="0 2,16 14" />
</g>
<g class="clock__digit-strokes" data-strokes="0" transform="translate(2,42)">
<polyline class="clock__digit-stroke" points="2 0,2 16" />
<polyline class="clock__digit-stroke" points="6 0,6 16" />
<polyline class="clock__digit-stroke" points="10 0,10 16" />
</g>
</g>
<g class="clock__column" data-column="m" transform="translate(50,0)">
<g class="clock__digit-strokes" data-strokes="0" transform="translate(2,2)">
<polyline class="clock__digit-stroke" points="2 0,2 16" />
<polyline class="clock__digit-stroke" points="6 0,6 16" />
<polyline class="clock__digit-stroke" points="10 0,10 16" />
<polyline class="clock__digit-stroke" points="14 0,14 16" />
<polyline class="clock__digit-stroke" points="0 2,16 14" />
</g>
<g class="clock__digit-strokes" data-strokes="0" transform="translate(22,2)">
<polyline class="clock__digit-stroke" points="2 0,2 16" />
<polyline class="clock__digit-stroke" points="6 0,6 16" />
<polyline class="clock__digit-stroke" points="10 0,10 16" />
<polyline class="clock__digit-stroke" points="14 0,14 16" />
<polyline class="clock__digit-stroke" points="0 2,16 14" />
</g>
.........完整代码请登录后点击上方下载按钮下载查看
网友评论0