d3与spliting实现文字环绕动画效果
代码语言:html
所属分类:动画
代码描述:d3与spliting实现文字环绕动画效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> @import url("https://fonts.googleapis.com/css?family=Lato&display=swap"); * { box-sizing: border-box; } body { min-height: 100vh; display: -webkit-box; display: flex; -webkit-box-align: center; align-items: center; -webkit-box-pack: center; justify-content: center; font-family: 'Lato', sans-serif; } .container { height: 40vmin; position: relative; width: 40vmin; width: calc((112.748 / 241.22) * 40vmin); } .char { --delay: calc(((var(--char-total) - var(--char-index))) - var(--word-index)); offset-path: path(var(--path)); -webkit-animation: travel 6s calc((var(--delay) * (0.15)) * -1s) infinite linear both; animation: travel 6s calc((var(--delay) * (0.15)) * -1s) infinite linear both; offset-rotate: auto 180deg; position: absolute !important; font-size: 4vmin; font-weight: bold; top: 0%; left: 0%; -webkit-transform: translate(0, -2.5vmin); transform: translate(0, -2.5vmin); } svg { height: 100%; width: 100%; } path { stroke: #111; stroke-width: 2.5px; fill: rgba(0,64,255,0.25); fill: url("#popsicle-gradient"); } .gradient { height: 0; width: 0; } @-webkit-keyframes travel { from { offset-distance: 0%; } to { offset-distance: 100%; } } @keyframes travel { from { offset-distance: 0%; } to { offset-distance: 100%; } } </style> </head> <body translate="no"> <div class="container"> <svg xmlns="http://www.w3.org/2000/svg" viewbox="0 -2 112.748 246.22"> <lineargradient id="popsicle-gradient" gradientunits="userSpaceOnUse" x1="0%" y1="0%" x2="100%" y2="0%" gradientTransform="rotate(45) scale(2)"> <stop offset="0%" stop-color="hsl(180, 100%, 50%)" stop-opacity="1"></stop> <stop offset="19%" stop-color="hsl(180, 100%, 50%)" stop-opacity="1"></stop> <stop offset="20%" stop-color="hsl(100, 100%, 50%)" stop-opacity="1"></stop> <stop offset="39%" stop-color="hsl(100, 100%, 50%)" stop-opacity="1"></stop> <stop offset="40%" stop-color="hsl(305, 100%, 75%)" stop-opacity="1"></stop> <stop offset="59%" stop-color="hsl(305, 100%, 75%)" stop-opacity="1"></stop> <stop offset="60%" stop-color="hsl(250, 100%, 65%)" stop-opacity="1"></stop> <stop offset="79%" stop-color="hsl(250, 100%, 65%)" stop-opacity="1"></stop> <stop offset="80%" stop-color="hsl(6.........完整代码请登录后点击上方下载按钮下载查看
网友评论0