js+css实现2023年一年中当前过完的时间进度条效果代码

代码语言:html

所属分类:进度条

代码描述:js+css实现2023年一年中当前过完的时间进度条效果代码

代码标签: js css 2023 时间 进度条

下面为部分代码预览,完整代码请点击下载或在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),90%,10%);
	--fg: hsl(var(--hue),90%,90%);
	--fill: hsl(133,90%,40%);
	--trans-dur: 0.3s;
	font-size: calc(16px + (24 - 16) * (100vw - 320px) / (2560 - 320));
}
body,
button {
	font: 1em/1.5 "DM Sans", sans-serif;
}
body {
	background-color: var(--bg);
	color: var(--fg);
	height: 100vh;
}
.yr-progress {
	margin: auto;
	padding: 6em 0 1.5em 0;
	text-align: center;
	width: calc(100% - 2em);
}
.yr-progress__bar {
	background-color: hsla(0,0%,100%,0.05);
	border-radius: 1em;
	box-shadow:
		0 0.125em 0.125em hsla(0,0%,100%,0.2) inset,
		0 -0.125em 0.125em hsla(0,0%,100%,0.3) inset;
	margin: 0 0.75em;
	padding: 0.25em;
	position: relative;
	max-width: 27em;
	width: 100%;
	height: 2em;
}
.yr-progress__bar-fill-wrap,
.yr-progress__bar-fill {
	overflow: hidden;
}
.yr-progress__bar-fill-wrap {
	border-radius: 0.75em;
	position: absolute;
	inset: 0.25em;
	z-index: -1;
}
.yr-progress__bar-fill-wrap--glow {
	border-radius: 1.25em;
	filter: blur(8px);
	inset: -0.25em;
	opacity: 0.7;
}
.yr-progress__bar-fill {
	width: 100%;
	height: 100%;
	transform: translate3d(-100%,0,0);
	transition: transform var(--trans-dur) ease-in-out;
}
.yr-progress__bar:before,
.yr-progress__bar-fill:before {
	content: "";
	display: block;
	position: absolute;
}
.yr-progress__bar:before {
	border-radius: 0.6em;
	box-shadow:
		0 0.4em 0 hsla(0,0%,100%,0.6) inset,
		0 -0.25em 0 hsla(0,0%,100%,0.5) inset;
	filter: blur(2px);
	top: 0.25em;
	left: 0.25em;
	width: calc(100% - 0.5em);
	height: 1.5em;
}
.yr-progress__bar-fill:before {
	background-color: var(--fill);
	width: 100%;
	height: 100%;
}
.yr-progress__bar-fill-sr {
	position: absolute;
	overflow: hidden;
	width: 1px;
	height: 1px;
}
.yr-progress__bar-divs {
	display: flex;
	position: absolute;
	top: 0;
	left: 0.25em;
	width: calc(100% - 0.5em);
	height: 100%;
}
.yr-progress__bar-div {
	box-shadow: -1px 0 0 hsla(0,0%,100%,0.3) inset, 1px 0 0 hsla(0,0%,0%,0.2) inset;
	width: 100%;
	height: 100%;
}
.yr-progress__bar-div:first-child {
	box-shadow: -1px 0 0 hsla(0,0%,100%,0.3) inset;
}
.yr-progress__bar-div:last-child {
	box-shadow: 1px 0 0 hsla(0,0%,0%,0.2) inset;
}
.yr-progress__checkbox {
	margin-right: 0.75em;
}
.yr-progress__label {
	display: inline-flex;
	align-items: center;
	margin-bottom: 1.5em;
	-webkit-tap-highlight-color: transparent;
}
.yr-progress__percent,
.yr-progress__yr {
	font-size: 1.5em;
	line-height: 1;
}
.yr-progress__percent {
	font-weight: 700;
	margin-bottom: 1.5rem;
}
.yr-progress__stats {
	border-radius: 0.25em;
	margin: 0 auto 1.5em auto;
	max-width: 15em;
	padding: 0.375em 0;
	transition: background-color var(--trans-dur) linear;
}
.yr-progress__stat-summary {
	cursor: pointer;
	font-weight: 700;
	outline: transparent;
}
.yr-progress__stat-label {
	color: hsl(var(--hue),90%,70%);
	font-size: 0.75em;
	line-height: 1;
	margin-top: 0.375rem;
}
.yr-progress__stat-value small {
	font-size: 0.75em;
}
.yr-progress__stats:hover {
	background-color: hsl(var(--hue),90%,20%);
}
.yr-progress__wrap {
	display: flex;
	justify-content: center;
	align-items: center;
	margin-bottom: 1.5em;
}
.yr-progress__yr {
	text-align: right;
	width: 4.5rem;
}
.yr-progress__yr ~ .yr-progress__yr {
	text-align: left;
}

/* `:has()` support */
@supports selector(:has(+ *)) {
	.yr-progress__stats:has(.yr-progress__stat-summary:focus-visible) {
		background-color: hsl(var(--hue),90%,20%);
	}
}
</style>



</head>

<body>
  <form class="yr-progress">
	<div class="yr-progress__wrap">
		<div class="yr-progress__yr" data-yr-start>-</div>
		<div class="yr-progress__bar">
			<div class="yr-progress__bar-fill-wrap yr-progress__bar-fill-wrap--glow">
				<div class="yr-progress__bar-fill" data-fill></div>
			</div>
			<div class="yr-progress__bar-fill-wrap">
				<span id="yr-progress" class="yr-progress__bar-fill-sr">Year Progress</span>
				<div aria-labelledby="yr-progress" class="yr-progress__bar-fill" role="progressbar" aria-valuemin="0" aria-valuenow="0" aria-valuemax="100" data-fill></div>
			</div>
			<div class="yr-progress__bar-divs">
				<div class="yr-progress__bar-div"></div>
				<div class="yr-progress__bar-div"></div>
				<div class="yr-progress__bar-div"></div>
				<div class="yr-progress__bar-div"></div>
				<div class="yr-progress__bar-div"></div>
				<div class="yr-progress__bar-div"></div>
				<div class="yr-progress__bar-div"></div>
				<div class="yr-progress__bar-div"></div>
				<div class="yr-progress__bar-div"></div>
				<div class="yr-progress__bar-div"></div>
				<div class="yr-progress__bar-div"></div>
				<div class="yr-progress__bar-div"></div>
			</div>
		</div>
		<div class="yr-progress__yr" data-yr-end>-</div>
	</d.........完整代码请登录后点击上方下载按钮下载查看

网友评论0