Dragonball Online Goku Hand
본문 바로가기
CSS

[CSS] SVG animation

by 별의 코비 2022. 9. 8.
728x90

CSS를 이용해서 text animation을 만들어봅시다!


@keyframes를 이용하여 애니메이션을 줍니다.


애니메이션 코드 소스를 알아봅시다.💻

✔️HTML

<svg viewBox="0 0 1320 300">
    <text x="50%" y="50%" dy="40px" text-anchor="middle">noeyheyh</text>
</svg>

✔️CSS

@font-face {
    font-family: 'Jalnan';
    font-weight: normal;
    font-style: normal;
    src: url('https://cdn.jsdelivr.net/gh/webfontworld/goodchoice/Jalnan.eot');
    src: url('https://cdn.jsdelivr.net/gh/webfontworld/goodchoice/Jalnan.eot?#iefix') format('embedded-opentype'),
        url('https://cdn.jsdelivr.net/gh/webfontworld/goodchoice/Jalnan.woff2') format('woff2'),
        url('https://cdn.jsdelivr.net/gh/webfontworld/goodchoice/Jalnan.woff') format('woff'),
        url('https://cdn.jsdelivr.net/gh/webfontworld/goodchoice/Jalnan.ttf') format("truetype");
    font-display: swap;
}
body {
  background-color: pink;
}
svg {
  font-family: 'Jalnan';
  font-size: 140px;
  position: absolute;
  width: 100%;
  height: 100%;
  text-transform: uppercase;
  animation: stroke 5s 1 alternate;
  fill: rgba(255,255,255,1);
  
}
@keyframes stroke {
  0% {
    stroke-dashoffset: 25%;
    stroke-dasharray: 0 50%;
    fill: rgba(255,255,255,0);
    stroke: rgba(255,153,153,1);
    stroke-width:2;
  }
  70% {
    fill: rgba(255,255,255,0);
    stroke: rgba(255,153,153,1);
  }
  80% {
    fill: rgba(255,255,255,0);
    stroke: rgba(255,153,1513,1);
  }
  100% {
    stroke-dashoffset: -25%;
    stroke-dasharray: 50% 0;
    fill: rgba(255,255,255,1);
    stroke: rgba(155,153,153,0);
    stroke-width:0;
  }
}

'CSS' 카테고리의 다른 글

[CSS] CSS animation  (11) 2022.09.08
[CSS] CSS intro  (5) 2022.09.08
[CSS] SVG intro  (2) 2022.09.08
[CSS] "통통튀는 공" 을 만들어봅시다!  (5) 2022.09.02
[CSS] "동 to the 그 to the 라미 애니메이션" 을 만들어봅시다!  (15) 2022.08.29

댓글