js+css实现中性简洁时钟指针走动显示时间代码

代码语言:html

所属分类:布局界面

代码描述:js+css实现中性简洁时钟指针走动显示时间代码

代码标签: js css 中性 简洁 时钟 指针 走动 显示 时间 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
 
<meta charset="UTF-8">
 


 
 
 
<style>
* {
        border: 0;
        box-sizing: border-box;
        margin: 0;
        padding: 0;
}
:root {
        --hue: 223;
        --bg: hsl(var(--hue),10%,90%);
        --fg: hsl(var(--hue),10%,10%);
        --primary: hsl(var(--hue),90%,50%);
        --shadow1: hsl(var(--hue),10%,80%);
        --shadow2: hsl(var(--hue),10%,100%);
        --trans-dur: 0.3s;
        font-size: calc(16px + (24 - 16) * (100vw - 320px) / (2560 - 320));
}
body {
        background-color: var(--bg);
        color: var(--fg);
        display: flex;
        font: 1em/1.5 sans-serif;
        height: 100vh;
}
.clock,
.clock:before,
.clock__tick:before {
        animation-duration: 0.6s;
        animation-timing-function: ease-in-out;
        animation-fill-mode: forwards;
}
.clock {
        animation-name: clockOuter;
        background-color: var(--bg);
        border-radius: 50%;
        box-shadow:
                0 0 0 var(--shadow1),
                0 0 0 var(--shadow2);
        margin: auto;
        position: relative;
        width: 16em;
        height: 16em;
}
.clock:before,
.clock__hand,
.clock__hand:before,
.clock__tick,
.clock__tick:before {
        position: absolute;
}
.clock:before,
.clock__hand:before,
.clock__tick:before {
        content: "";
        display: block;
}
.clock:before {
        animation-name: clockInner;
        border-radius: inherit;
        box-shadow:
                0 0 0 var(--shadow1),
                0 0 0 var(--shadow2);
        top: calc(50% - 4em);
        left: calc(50% - 4em);
        width: 8em;
        height: 8em;
        z-index: 1;
}
.clock__hand,
.clock__hand:before {
        transform-origin: 50% calc(100% - 1em);
}
.clock__hand {
        bottom: calc(50% - 1em);
        left: calc(50% - 0.125em);
        width: 0.25em;
        transform: scaleY(0);
        z-index: 2;
}
.clock__hand:before {
        width: 100%;
        height: 100%;
}
.clock__hand--hr {
        height: 4em;
}
.clock__hand--hr:before {
        background-color: hsl(var(--hue),10%,50%);
}
.clock__hand--min {
        height: 6em;
}
.clock__hand--min:before {
        background-color: var(--fg);
}
.clock__hand--sec {
        height: 7em;
}
.clock__hand--sec:before {
        background-color: var(--primary);
}
.clock--moving .clock__hand--sec:before {
        animation: clockSecondHand 0.5s ease-in-out;
}
.clock__tick {
        bottom: 50%;
        left: calc(50% - 0.125em);
        width: 0.25em;
        height: 1.25em;
        transform-origin: 50% 100%;
}
.clock__tick:before {
        background-color: hsla(var(--hue),10%,50%,0.5);
        animation-name: clockTick;
        width: 100%;
        height: 100%;
        transform-origi.........完整代码请登录后点击上方下载按钮下载查看

网友评论0