js+css实现立体木箱子时钟指针走动显示当前时间代码

代码语言:html

所属分类:布局界面

代码描述:js+css实现立体木箱子时钟指针走动显示当前时间代码

代码标签: js css 立体 木箱子 时钟 指针 走动 显示 当前 时间 代码

下面为部分代码预览,完整代码请点击下载或在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">
  
  
  
<style>
* {
	border: 0;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
:root {
	--hue: 223;
	--bg: hsl(var(--hue),10%,70%);
	--fg: hsl(var(--hue),10%,10%);
	--trans-dur: 0.3s;
	font-size: calc(16px + (32 - 16) * (100vw - 320px) / (2560 - 320));
}
body {
	background-color: var(--bg);
	background-image: linear-gradient(-45deg,hsla(var(--hue),10%,10%,0.4),hsla(var(--hue),10%,10%,0));
	color: var(--fg);
	display: flex;
	font: 1em/1.5 sans-serif;
	height: 100vh;
	transition:
		background-color var(--trans-dur),
		color var(--trans-dur);
}
.clock {
	--hrAngle: 0;
	--minAngle: 0;
	margin: auto;
	perspective: 40em;
	position: relative;
	width: 16em;
	height: 16em;
}
.clock__hands,
.clock__hand,
.clock__hand-hub,
.clock__shadow,
.clock__side,
.clock__side {
	position: absolute;
}
.clock__hands,
.clock__side {
	top: 50%;
	left: 50%;
}
.clock__hands {
	filter: drop-shadow(-0.25em 0.25em 0.125em hsla(0,0%,0%,0.5))
}
.clock__hand,
.clock__hand-hub {
	background-color: hsl(var(--hue),10%,10%);
}
.clock__hand {
	bottom: -1em;
	left: calc(50% - 0.125em);
	width: 0.25em;
	height: 6em;
	transform-origin: 50% calc(100% - 1em);
}
.clock__hand-hub {
	border-radius: 50%;
	top: -0.375em;
	left: -0.375em;
	width: 0.75em;
	height: 0.75em;
}
.clock__hand--h {
	height: 5em;
	transform: rotate(var(--hrAngle));
}
.clock__hand--m {
	transform: rotate(var(--minAngle));
}
.clock__shadow {
	filter: blur(0.25em);
	width: 100%;
	height: 100%;
}
.clock__shadow:before,
.clock__shadow::after {
	background-color: hsla(var(--hue),10%,10%,0.7);
	content: "";
	display: block;
	position: absolute;
}
.clock__shadow:before {
	clip-path: polygon(1.25em 0,100% 0,100% 100%,1.5em 100%,0 1em);
	top: 6em;
	left: 1em;
	width: 12.25em;
	height: 5.5em;
}
.clock__shadow:after {
	clip-path: polygon(0 0,100% 0,100% 0.125em,5em 100%);
	top: 11.5em;
	left: 2.5em;
	width: 10.75em;
	height: 5em;
}
.clock__sides {
	width: 100%;
	height: 100%;
	transform: rotateX(-35deg);
	transform-style: preserve-3d;
}
.clock__side {
	background: url(//repo.bfw.wiki/bfwrepo/image/6533297e4c1d7.png) 0 0 / 200% 200%;
	width: 8em;
	height: 8em;
	transform: translate(-50%,-50%) rotateX(90deg) rotateZ(45deg) translateZ(4em);
}
.clock__side:nth-child(2) {
	background-position: 0 100%;
	transform: translate(-50%,-50%) rotateY(-45deg) translateZ(4em);
}
.clock__side:nth-child(3) {
	background-position: 100% 0;
	transform: translate(-50%,-50%) rotateY(45deg) translateZ(4em);
}

/* Dark theme */
@media (pref.........完整代码请登录后点击上方下载按钮下载查看

网友评论0