css实现拉伸的咖啡loading加载动画效果代码

代码语言:html

所属分类:加载滚动

代码描述:css实现拉伸的咖啡loading加载动画效果代码

代码标签: css 拉伸 咖啡 loading 加载 动画

下面为部分代码预览,完整代码请点击下载或在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%,90%);
	--fg: hsl(var(--hue),10%,10%);
	--primary: hsl(var(--hue),90%,55%);
	--trans-dur: 0.3s;
	font-size: calc(16px + (20 - 16) * (100vw - 320px) / (1280 - 320));
}
body {
	background-color: var(--bg);
	color: var(--fg);
	font: 1em/1.5 sans-serif;
	height: 100vh;
	display: grid;
	place-items: center;
	transition:
		background-color var(--trans-dur),
		color var(--trans-dur);
}
.coffee {
	font-size: 0.6em;
	position: relative;
	width: 21.5em;
	height: 9em;
}
.coffee:before {
	border-bottom: 0.25em dashed;
	content: "";
	display: block;
	position: absolute;
	top: 7.5em;
	width: 100%;
}
.coffee__cup,
.coffee__cup-part,
.coffee__cup-handle,
.coffee__steam-part {
	animation-duration: 8s;
	animation-iteration-count: infinite;
}
.coffee__cup,
.coffee__cup-part,
.coffee__cup-handle {
	animation-timing-function: cubic-bezier(0.9,0,0.1,1);
}
.coffee__cup {
	animation-name: cup;
	position: relative;
	width: 11.25em;
	height: 9em;
}
.coffee__cup-part {
	background-color: var(--bg);
	position: absolute;
	transition:
		background-color var(--trans-dur),
		box-shadow var(--trans-dur);
}
.coffee__cup-part--a {
	animation-name: cup-part-a;
	border-radius: 5.625em 5.625em 5.625em 5.625em / 2em 2em 2.7em 2.7em;
	box-shadow: 0 0 0 0.3em var(--fg) inset;
	top: 4.3em;
	width: 11.25em;
	height: 4.7em;
}
.coffee__cup-part--b {
	animation-name: cup-part-b;
	background-color: transparent;
	border-radius: 5.625em / 2em;
	box-shadow: 0 0 0 0.2em var(--fg) inset;
	top: 4.3em;
	width: 11.25em;
	height: 4em;
}
.coffee__cup-part--c {
	animation-name: cup-part-c;
	border-radius: 1.7em / 0.45em;
	box-shadow: 0 0 0 0.2em var(--fg) inset;
	top: 7.1em;
	left: 3.925em;
	width: 3.4em;
	height: 0.9em;
}
.coffee__cup-part--d,
.coffee__cup-part--e,
.coffee__cup-part--f {
	z-index: 1;
}
.coffee__cup-part--d {
	animation-name: cup-part-d;
	border-radius: 3.6em 3.6em 3.3em 3.3em / 1em 1em 3.5em 3.5em;
	box-shadow: 0 0 0 0.2em var(--fg) inset;
	top: 2.55em;
	left: 2.025em;
	width: 7.2em;
	height: 5.15em;
}
.coffee__cup-part--e {
	animation-name: cup-part-e;
	background-color: var(--fg);
	box-shadow:
		0 0 0 0.2em var(--fg) inset,
		0 1em 0 var(--bg) inset;
	border-radius: 3.5em / 1em;
	top: 2.65em;
	left: 2.125em;
	width: 7em;
	height: 2em;
}
.coffee__cup-part--f {
	animation-name: cup-part-f;
	background-color: transparent;
	top: 4.1em;
	left: 5.925em;
	width: 4.8em;
	height: 3em;
}
.coffee__cup-handle {
	animation-name: cup-handle;
}
.coffee__cup,
.coffee__steam {
	transform: translateX(-50%);
}
.coffee__steam {
	display: block;
	position: absolute;
	top: 0;
	left: 0;
	width: 3.5em;
	height: 3.5em;
}
.coffee__steam--right {
	right: 0;
	left: auto;
	transform: translateX(50%);
}
.coffee__steam-part {
	animation-name: steam-left;
	aniamtion-timing-function: linear;
	stroke-dashoffset: 48;
}
.coffee__steam--right .coffee__steam-part {
	animation-name: steam-right;
	stroke-dashoffset: 35;
}
.coffee__steam-part--a {
	stroke-dasharray: 24 142;
}
.coffee__steam-part--b {
	stroke-dasharray: 30 8 10 130;
}
.coffee__steam-part--c {
	stroke-dasharray: 15 6 1 134;
}
.coffee__steam-part--d {
	stroke-dasharray: 18 6 1 90;
}
.coffee__steam-part--e {
	stroke-dasharray: 25 6 4 76;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
	:root {
		--bg: hsl(var(--hue),10%,10%);
		--fg: hsl(var(--hue),10%,90%);
	}
}

/* Animations */
@keyframes cup {
	from,
	25%,
	75%,
	to {
		left: 0;
	}
	50% {
		left: 21.5em;
	}
}
@keyframes cup-part-a {
	from,
	50%,
	to {
		width: 11.25em;
	}
	25%,
	75% {
		width: calc(11.25em + 21.5em);
	}
}
@keyframes cup-part-b {
	from,
	50%,
	to {
		width: 11.25em;
	}
	25%,
	75% {
		width: calc(11.25em + 21.5em);
	}
}
@keyframes cup-part-c {
	from,
	50%,
	to {
		width: 3.4em;
	}
	25%,
	75% {
		width: calc(3.4em + 21.5em);
	}
}
@keyframes cup-part-d {
	from,
	50%,
	to {
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0