svg+js实现时钟型撤销重做按钮点击动画效果代码

代码语言:html

所属分类:其他

代码描述:svg+js实现时钟型撤销重做按钮点击动画效果代码

代码标签: svg 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">
  
  
  
<style>
* {
	border: 0;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
:root {
	--hue: 223;
	--bg: hsl(var(--hue),90%,90%);
	--fg: hsl(var(--hue),90%,10%);
	--primary: hsl(var(--hue),90%,50%);
	--trans-dur: 0.3s;
	font-size: calc(60px + (90 - 60) * (100vw - 320px) / (2560 - 320));
}
body,
button {
	font: 1em/1.5 sans-serif;
}
body {
	background-color: var(--bg);
	color: var(--fg);
	display: flex;
	height: 100vh;
	transition:
		background-color var(--trans-dur),
		color var(--trans-dur);
}
.undo-redo,
.undo-redo__button {
	display: flex;
}
.undo-redo {
	background-color: hsl(var(--hue),90%,60%);
	border-radius: 0.75em;
	justify-content: space-between;
	margin: auto;
	position: relative;
	width: 3em;
	height: 1.5em;
}
.undo-redo__button {
	background-color: hsla(var(--hue),90%,70%,0);
	border-radius: 0.75em 0 0 0.75em;
	outline: transparent;
	padding: 0.25em 0.15em 0.25em 0.225em;
	align-items: center;
	width: 1.5em;
	height: 100%;
	transition: background-color var(--trans-dur) ease-in-out;
	-webkit-tap-highlight-color: transparent;
}
.undo-redo__button:nth-child(2) {
	border-radius: 0 0.75em 0.75em 0;
	justify-content: flex-end;
	padding: 0.25em 0.225em 0.25em 0.15em;
}
.undo-redo__button:disabled {
	cursor: not-allowed;
}
.undo-redo__button:not(:disabled) {
	cursor: pointer;
}
.undo-redo__button:not(:disabled):focus,
.undo-redo__button:not(:disabled):hover {
	background-color: hsla(var(--hue),90%,70%,1);
}
.undo-redo__clock,
.undo-redo__clock-hands,
.undo-redo__clock-hand,
.undo-redo__clock-tick,
.undo-redo__curtain {
	position: absolute;
}
.undo-redo__clock {
	background-color: hsl(0,0%,100%);
	border-radius: 50%;
	pointer-events: none;
	top: 0;
	left: calc(50% - 0.75em);
	width: 1.5em;
	height: 1.5em;
	transition: transform var(--trans-dur) cubic-bezier(0.58,0,0.42,1);
	z-index: 2;
}
.undo-redo__clock-hands {
	filter: drop-shadow(0.0625em 0.0625em hsl(var(--hue),90%,90%));
	top: 50%;
	left: 50%;
	transform: translate3d(0,0,0);
}
.undo-redo__clock-hand {
	background-color: var(--primary);
	border-radius: 0.1em;
	bottom: -0.05em;
	left: -0.05em;
	width: 0.1em;
	height: 0.55em;
	transform-origin: 50% calc(100% - 0.05em);
	transition: transform 0.45s cubic-bezier(0.58,0,0.42,1.42);
	z-index: 3;
}
.undo-redo__clock-hand--hr {
	transform: rotate(90deg);
	height: 0.375em;
}
.undo-redo__clock-tick {
	background-color: hsl(var(--hue),90%,70%);
	top: 50%;
	left: 50%;
	height: max(2px,0.1em);
	width: max(1px,0.05em);
	transform: translateX(-50%) translateY(-0.625em);
	transform-origin: 50% 0%;
}
.undo-redo__clock-tick:nth-child(2) { transform: translateX(-50%) rotate(30deg) translateY(-0.625em); }
.undo-redo__clock-tick:nth-child(3) { transform: translateX(-50%) rotate(60deg) translateY(-0.625em); }
.undo-redo__clock-tick:nth-child(4) { transform: translateX(-50%) rotate(90deg) translateY(-0.625em); }
.undo-redo__clock-tick:nth-child(5) { transform: translateX(-50%) rotate(120deg) translateY(-0.625em); }
.undo-redo__clock-tick:nth-child(6) { transform: translateX(-50%) rotate(150deg) translateY(-0.625em); }
.undo-redo__clock-tick:nth-child(7) { transform: translateX(-50%) rotate(180deg) translateY(-0.625em); }
.undo-redo__clock-tick:nth-child(8) { transform: translateX(-50%) rotate(210deg) translateY(-0.625em); }
.undo-redo__clock-tick:nth-child(9) { transform: translateX(-50%) rotate(240deg) translateY(-0.625em); }
.undo-redo__clock-tick:nth-child(10) { transform: translateX(-50%) rotate(270deg) translateY(-0.625em); }
.undo-redo__clock-tick:nth-child(11) { transform: translateX(-50%) rotate(300deg) translateY(-0.625em); }
.undo-redo__clock-tick:nth-child(12) { transform: translateX(-50%) rotate(330deg) translateY(-0.625em); }

.undo-redo__curtain {
	background-color: hsl(var(--hue),90%,60%);
	pointer-events: none;
	top: 0;
	left: 50%;
	width: 0.75em;
	height: 1.5em;
	transform: scaleX(0);
	transform-origin: 0 50%;
	transition: transform var(--trans-dur) cubic-bezier(0.58,0,0.42,1);
	z-index: 1;
}
.undo-redo__icon {
	color: hsl(0,0%,100%);
	pointer-events: none;
	width: 0.375em;
	height: 0.375em;
	transition: opacity var(--trans-dur) 0.15s ease-in-out;
}
.undo-redo__button:disabled .undo-redo__icon {
	opacity: 0.4;
}
.undo-redo__sr {
	overflow: hidden;
	position: absolute;
	width: 1px;
	height: 1px;
}

/* when :active */
.undo-redo__button:not(:disabled):active ~ .undo-redo__clock {
	transform: translateX(-0.75em);
}
.undo-redo__button:not(:disabled):active ~ .undo-redo__clock .undo-redo__clock-hand--min {
	transform: rotate(-360deg);
}
.undo-redo__button:not(:disabled):active ~ .undo-redo__clock .undo.........完整代码请登录后点击上方下载按钮下载查看

网友评论0