svg+css实现足球轨迹运动loading加载动画效果代码

代码语言:html

所属分类:加载滚动

代码描述:svg+css实现足球轨迹运动loading加载动画效果代码

代码标签: svg 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: 210;
  --bg: hsl(var(--hue),10%,85%);
  --fg: hsl(var(--hue),10%,15%);
  --red: hsl(344,75%,40%);
  --white: hsl(0,0%,100%);
  --blue: hsl(213,81%,21%);
  --trans-dur: 0.3s;
  font-size: clamp(1rem,0.95rem + 0.25vw,1.25rem);
}

body {
  background-color: var(--bg);
  color: var(--fg);
  display: flex;
  font: 1em/1.5 sans-serif;
  height: 100vh;
  transition: background-color var(--trans-dur), color var(--trans-dur);
}

.pl {
  --dur: 3s;
  display: block;
  margin: auto;
  width: 14em;
  height: auto;
}
.pl__ball, .pl__ball-shadow, .pl__ball-texture, .pl__stripe, .pl__stripe-dot, .pl__stripe-rotate {
  animation-duration: var(--dur);
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
.pl__ball {
  animation-name: ball;
}
.pl__ball-shadow {
  animation-name: ball-shadow;
}
.pl__ball-texture {
  animation-name: ball-texture;
}
.pl__stripe {
  animation-name: stripe;
}
.pl__stripe--1 {
  animation-name: stripe1;
}
.pl__stripe--2 {
  animation-name: stripe2;
}
.pl__stripe--3 {
  animation-name: stripe3;
}
.pl__stripe-dot {
  animation-name: stripe-dot;
}
.pl__stripe-dot-group:nth-child(1) .pl__stripe-dot:nth-child(2) {
  animation-delay: calc(var(--dur) * 0.2333333333);
}
.pl__stripe-dot-group:nth-child(1) .pl__stripe-dot:nth-child(3) {
  animation-delay: calc(var(--dur) * 0.3);
}
.pl__stripe-dot-group:nth-child(1) .pl__stripe-dot:nth-child(4) {
  animation-delay: calc(var(--dur) * 0.45);
}
.pl__stripe-dot-group:nth-child(1) .pl__stripe-dot:nth-child(5) {
  animation-delay: calc(var(--dur) * 0.6833333333);
}
.pl__stripe-dot-group:nth-child(1) .pl__stripe-dot:nth-child(6) {
  animation-delay: calc(var(--dur) * 0.7083333333);
}
.pl__stripe-dot-group:nth-child(1) .pl__stripe-dot:nth-child(7) {
  animation-delay: calc(var(--dur) * 0.8416666667);
}
.pl__stripe-dot-group:nth-child(2) .pl__stripe-dot:nth-child(1) {
  animation-delay: calc(var(--dur) * 0.1083333333);
}
.pl__stripe-dot-group:nth-child(2) .pl__stripe-dot:nth-child(2) {
  animation-delay: calc(var(--dur) * 0.3333333333);
}
.pl__stripe-dot-group:nth-child(2) .pl__stripe-dot:nth-child(3) {
  animation-delay: calc(var(--dur) * 0.425);
}
.pl__stripe-dot-group:nth-child(2) .pl__stripe-dot:nth-child(4) {
  animation-delay: calc(var(--dur) * 0.6);
}
.pl__stripe-dot-group:nth-child(2) .pl__stripe-dot:nth-child(5) {
  animation-delay: calc(var(--dur) * 0.6583333333);
}
.pl__stripe-dot-group:nth-child(2) .pl__stripe-dot:nth-child(6) {
  animation-delay: calc(var(--dur) * 0.8083333333);
}
.pl__stripe-dot-group:nth-child(2) .pl__stripe-dot:nth-child(7) {
  animation-delay: calc(var(--dur) * 0.8416666667);
}
.pl__stripe-dot-group:nth-child(2) .pl__stripe-dot:nth-child(8) {
  animation-delay: calc(var(--dur) * 0.8916666667);
}
.pl__stripe-dot-group:nth-child(3) .pl__stripe-dot:nth-child(1) {
  animation-delay: calc(var(--dur) * -0.0666666667);
}
.pl__stripe-dot-group:nth-child(3) .pl__stripe-dot:nth-child(2) {
  animation-delay: calc(var(--dur) * 0.0583333333);
}
.pl__stripe-dot-group:nth-child(3) .pl__stripe-dot:nth-child(3) {
  animation-delay: calc(var(--dur) * 0.2083333333);
}
.pl__stripe-dot-group:nth-child(3) .pl__stripe-dot:nth-child(4) {
  animation-delay: calc(var(--dur) * 0.4);
}
.pl__stripe-dot-group:nth-child(3) .pl__stripe-dot:nth-child(5) {
  animation-delay: calc(var(--dur) * 0.5166666667);
}
.pl__stripe-dot-group:nth-child(3) .pl__stripe-dot:nth-child(6) {
  animation-delay: calc(var(--dur) * 0.625);
}
.pl__stripe-dot-group:nth-child(3) .pl__stripe-dot:nth-child(7) {
  animation-delay: calc(var(--dur) * 0.7666666667);
}
.pl__stripe-rotate {
  animation-name: stripe-rotate;
}

/* Animation */
@keyframes ball {
  from {
    transform: rotate(0) translate(0, -15.75px);
  }
  to {
    transform: rotate(1turn) translate(0, -15.75px);
  }
}
@keyframes ball-shadow {
  from {
    transform: rotate(0);
  }
  to {
    transform: rotate(-1turn);
  }
}
@keyframes ball-texture {
  from {
    transform: translate(-16px, 0);
  }
  to {
    transform: translate(48px, 0);
  }
}
@keyframes stripe-dot {
  from {
    r: 1.25px;
  }
  16.67%, to {
    r: 0;
  }
}
@keyframes stripe-rotate {
  from {
    transform: rotate(0);
  }
  to {
    transform: rotate(1turn);
  }
}
@keyframes stripe1 {
  from, to {
    stroke-dashoffset: -95.7745;
  }
  50% {
    animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
    stroke-dashoffset: -75.702;
  }
}
@keyframes stripe2 {
  from, to {
    stroke-dashoffset: -80.1;
  }
  50% {
    animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
    stroke-dashoffset: -53.4;
  }
}
@keyframes stripe3 {
  from, to {
    stroke-dashoffset: -72.765;
  }
  50% {
    animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
    stroke-dashoffset: -48.51;
  }
}
</style>


  
  
</head>

<body translate="no">
  <svg class="pl" viewBox="0 0 56 56" width="56px" height="56px" role="img" aria-label="Soccer ball rolling in circles, emitting red, white, and blue stripes that move along with the ball and leave behind dots of the same colors that shrink">
	<clipPath id="ball-clip">
		<circle r="8" />
	</clipPath>
	<defs>
		<path id="hex" d="M 0 -9.196 L 8 -4.577 L 8 4.661 L 0 9.28 L -8 4.661 L -8 -4.577 Z" />
		<g id="hex-chunk" fill="none" stroke="hsl(var(--hue),10%,10%)" stroke-width="0.5">
			<use href="#hex" fill="hsl(var(--hue),10%,10%)" />
			<use href="#hex" transform="translate(16,0)"/>
			<use href="#hex" tran.........完整代码请登录后点击上方下载按钮下载查看

网友评论0