svg+css实现调皮的loading圆圈加载动画效果代码
代码语言:html
所属分类:加载滚动
代码描述:svg+css实现调皮的loading圆圈加载动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <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%); --themeTrans: 0.3s; font-size: calc(16px + (24 - 16) * (100vw - 320px) / (1280 - 320)); } body { background: var(--bg); color: var(--fg); font: 1em/1.5 sans-serif; height: 100vh; display: grid; place-items: center; transition: background-color var(--themeTrans); } main { padding: 1.5em 0; } .pl { width: 11em; height: 10em; } .pl__ring, .pl__worm1, .pl__worm2, .pl__worm3 { animation-duration: 4s; animation-iteration-count: infinite; } .pl__ring { stroke: hsla(var(--hue),10%,10%,0.1); transition: stroke var(--themeTrans); } .pl__worm1 { animation-name: worm1; } .pl__worm2 { animation-name: worm2; transform-origin: 32px 88px; } .pl__worm3 { animation-name: worm3; transform-origin: 144px 88px; } /* Dark theme */ @media (prefers-color-scheme: dark) { :root { --bg: hsl(var(--hue),10%,10%); --fg: hsl(var(--hue),10%,90%); } .pl__ring { stroke: hsla(var(--hue),10%,90%,0.1); } } /* Animations */ @keyframes worm1 { from { animation-timing-function: ease-out; stroke-dashoffset: 43.98; } 12.5% { animation-timing-function: ease-in-out; stroke-dashoffset: -131.95; } 25% { animation-timing-function: ease-in; stroke-dashoffset: 0; } 37.5%, 50% { animation-timing-function: ease-out; stroke-dashoffset: -175.93; } 62.5% { animation-timing-function: ease-in-out; stroke-dashoffset: 0; } 75% { animation-timing-function: ease-in; stroke-dashoffset: -131.95; } 87.5%, to { stroke-dashoffset: 43.98; } } @keyframes worm2 { from, 35.5% { animation-timing-function: linear; stroke-dasharray: 0 40 0 44; visibility: hidden; transform: translate(0,0) rotate(0); } 37.5% { animation-timing-function: ease-out; stroke-dasharray: 0 40 44 0; visibility: visible; transform: translate(0,0) rotate(0); } 47.5% { animation-timing-function: ease-in; stroke-dasharray: 0 4 40 40; visibility: visible; transform: tran.........完整代码请登录后点击上方下载按钮下载查看
网友评论0