svg+ccss实现文字描边入场动画效果代码

代码语言:html

所属分类:动画

代码描述:svg+ccss实现文字描边入场动画效果代码

代码标签: svg ccss 文字 描边 入场 动画

下面为部分代码预览,完整代码请点击下载或在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),90%,90%);
       
--fg: hsl(var(--hue),90%,10%);
       
--primary: hsl(var(--hue),90%,50%);
       
--secondary: hsl(198,90%,50%);
       
--trans-dur: 0.3s;
       
font-size: calc(16px + (48 - 16) * (100vw - 320px) / (2560 - 320));
}
body
{
       
background-color: var(--bg);
       
color: var(--fg);
       
font: 1em/1.5 sans-serif;
       
display: flex;
       
height: 100vh;
       
transition:
                background-color var
(--trans-dur),
                color var
(--trans-dur);
}
.logo {
       
--anim-dur: 4s;
       
display: block;
       
overflow: visible;
       
margin: auto;
       
width: 13.5em;
       
height: auto;
}
.logo__fill,
.logo__letter,
.logo__letter path {
       
animation: logoFill var(--anim-dur) cubic-bezier(0.65,0,0.35,1) infinite;
}
.logo__fill {
       
transform: translateX(-100%);
}
.logo__letter {
       
animation-name: logoLetter;
       
animation-timing-function: cubic-bezier(0.37,-0.67,0.63,1.67);
       
transform: translateY(50%);
}
.logo__letter path {
       
animation-name: logoStroke1;
       
stroke-dasharray: 107 107;
       
stroke-dashoffset: -107;
}
.logo__letter:nth-child(2),
.logo__letter:nth-child(2) path {
       
animation-delay: calc(var(--anim-dur) * 0.02);
}
.logo__letter:nth-child(2) path {
       
animation-name: logoStroke2;
       
stroke-dasharray: 59 59;
       
stroke-dashoffset: -59;
}
.logo__letter:nth-child(3),
.logo__letter:nth-child(3) path {
       
animation-delay: calc(var(--anim-dur) * 0.04);
}
.logo__letter:nth-child(3) path {
       
animation-name: logoStroke3;
       
stroke-dasharray: 107 107;
       
stroke-dashoffset: -107;
}
.logo__letter:nth-child(4),
.logo__letter:nth-child(4) path {
       
animation-delay: calc(var(--anim-dur) * 0.06);
}
.logo__letter:nth-child(4) path {
       
animation-name: logoStroke4;
       
stroke-dasharray: 59 59;
       
stroke-dashoffset: -59;
}
.logo__letter:nth-child(5),
.logo__letter:nth-child(5) path {
       
animation-delay: calc(var(--anim-dur) * 0.08);
}
.logo__letter:nth-child(5) path {
       
animation-name: logoStroke5;
       
stroke-dasharray: 118 118;
       
stroke-dashoffset: -118;
}
.logo__letter:nth-child(6),
.logo__letter:nth-child(6) path {
       
animation-delay: calc(var(--anim-dur) * 0.1);
}
.logo__letter:nth-child(6) path {
       
animation-name: logoStroke6;
       
stroke-dasharray: 100 100;
       
stroke-dashoffset: -100;
}
.logo__letter:nth-child(7),
.logo__letter:nth-child(7) path {
       
animation-delay: calc(var(--anim-dur) * 0.12);
}
.logo__letter:nth-child(7) path {
       
animation-name: logoStroke7;
       
stroke-dasharray: 130 130;
       
stroke-dashoffset: -130;
}
.logo__letter:nth-child(8),
.logo__letter:nth-child(8) path {
       
animation-delay: calc(var(--anim-dur) * 0.14);
}
.logo__letter:nth-child(8) path {
       
animation-name: logoStroke8;
       
stroke-dasharray: 118 118;
       
stroke-dashoffset: -118;
}
.logo__letter:last-child,
.logo__letter:last-child path {
       
animation-delay: calc(var(--anim-dur) * 0.16);
}
.logo__letter:last-child path {
       
animation-name: logoStroke9;
       
stroke-dasharray: 113 113;
       
stroke-dashoffset: -113;
}

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

/* Animations */
@keyframes logoFill {
        from
, 25% { transform: translateX(-100%); }
       
40%, 65% { transform: translateX(0); }
       
80%, to { transform: translateX(100%); }
}
@keyframes logoLetter {
        from
, 85%, to { transform: translateY(50%); }
       
20%, 70% {
               
animation-timing-function: cubic-bezier(0.37,0,0.63,1);
               
transform: translateY(0);
       
}
}
@keyframes logoStroke1 {
        from
{ stroke-dashoffset: -107; }
       
20%, 70% { stroke-dashoffset: 0; }
       
85%, to { stroke-dashoffset: 107; }
}
@keyframes logoStroke2 {
        from
{ stroke-dashoffset: -59; }
       
20%, 70% { stroke-dashoffset: 0; }
       
85%, to { stroke-dashoffset: 59; }
}
@keyframes logoStroke3 {
        from
{ stroke-dashoffset: -107; }
       
20%, 70% { stroke-dashoffset: 0; }
       
85%, to { stroke-dashoffset: 107; }
}
@keyframes logoStroke4 {
        from
{ stroke-dashoffset: -59; }
       
20%, 70% { stroke-dashoffset: 0; }
       
85%, to { stroke-dashoffset: 59; }
}
@keyframes logoStroke5 {
        from
{ stroke-dashoffset: -118; }
       
20%, 70% { stroke-dashoffset: 0; }
       
85%, to { stroke-dashoffset: 118; }
}
@keyframes logoStroke6 {
        from
{ stroke-dashoffset: -100; }
       
20%, 70% { stroke-dashoffset: 0; }
       
85%, to { stroke-dashoffset: 100; }
}
@keyframes logoStroke7 {
        from
{ stroke-dashoffset: -130; }
       
20%, 70% { stroke-dashoffset: 0; }
       
85%, to { stroke-dashoffset: 130; }
}
@keyframes logoStroke8 {
        from
{ stroke-dashoffset: -118; }
       
20%, 70% { stroke-dashoffset: 0; }
       
85%, to { stroke-dashoffset: 118; }
}
@keyframes logoStroke9 {
        from
{ stroke-dashoffset: -113; }
       
20%, 70% { stroke-dashoffset: 0; }
       
85%, to { stroke-dashoffset: 113; }
}
</style>

 
</head>

<body >
  <svg.........完整代码请登录后点击上方下载按钮下载查看

网友评论0