纯css实现声音静音动画效果
代码语言:html
所属分类:动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title> Volume Toggle Switch</title> <link rel="stylesheet" href="http://repo.bfw.wiki/bfwrepo/css/reset.min.css"> <style> .volume { --line: #fff; --line-width: 6px; --duration: .5s; position: relative; cursor: pointer; -webkit-tap-highlight-color: transparent; } .volume input { display: none; } .volume input + svg { display: block; fill: none; stroke: var(--line); stroke-linecap: round; stroke-linejoin: round; stroke-width: var(--line-width); width: 108px; height: 96px; } .volume input + svg path { -webkit-animation: var(--name) var(--duration) ease forwards; animation: var(--name) var(--duration) ease forwards; } .volume input + svg path:nth-child(2) { stroke-dashoffset: 1px; } .volume input + svg path:nth-child(3) { stroke-dashoffset: 1px; } .volume input:checked + svg path:nth-child(1) { --name: shape; } .volume input:checked + svg path:nth-child(2) { --name: small; } .volume input:checked + svg path:nth-child(3) { --name: large; } .volume input:not(:checked) + svg path:nth-child(1) { --name: shape-r; } .volume input:not(:checked) + svg path:nth-child(2) { --name: small-r; } .volume input:not(:checked) + svg path:nth-child(3) { --name: large-r; } @-webkit-keyframes small { 0%, 30% { stroke-dasharray: 0 0 30px 64px; } 40% { stroke-dashoffset: 16px; } 80%, 100% { stroke-dashoffset: 1px; } 70% { stroke-dasharray: 0 43px 30px 64px; } 100% { stroke-dasharray: 0 39px 30px 64px; } } @keyframes small { 0%, 30% { stroke-dasharray: 0 0 30px 64px; } 40% { stroke-dashoffset: 16px; } 80%, 100% { stroke-dashoffset: 1px; } 70% { stroke-dasharray: 0 43px 30px 64px; } 100% { stroke-dasharray: 0 39px 30px 64px; } } @-webkit-keyframes small-r { 0% { stroke-dasharray: 0 39px 30px 64px; } 0%, 40% { stroke-dashoffset: 1px; } 70% { stroke-dashoffset: 16px; } 70%, 100% { stroke-dasharray: 0 0 30px 64px; } } @keyframes small-r { 0% { stroke-dasharray: 0 39px 30px 64px; } 0%, 40% { stroke-dashoffset: 1px; } 70% { stroke-dashoffset: 16px; } 70%, 100% { stroke-dasharray: 0 0 30px 64px; } } @-webkit-keyframes large { 0%, 30% { stroke-dasharray: 0 0 50px 84px; } 40% { stroke-dashoffset: 16px; } 80%, 100% { stroke-dashoffset: 1px; } 70% { stroke-dasharray: 0 82px 32px 84px; } 100% { stroke-dasharray: 0 78px 32px 84px; } } @keyfra.........完整代码请登录后点击上方下载按钮下载查看
网友评论0