Animated Rainbow Nyan Cat
본문 바로가기
CSS/애니메이션

SVG 텍스트 애니메이션

by 이유나1 2022. 9. 8.
728x90
반응형

SVG

SVG는 Scalable Vector Graphics라는 뜻인데, 번역하자면 확장가능한 벡터 그래픽이다. 픽셀을 이용하여 그림을 그리는 png jpg 파일들과 다르게 벡터를 기반으로 이미지를 표현한다. 그러다보니 크기를 조절함에 따라 깨지는 것이 없고, 용량이 작기 때문에 웹에서 자주 사용하는 이미지 형식입니다.

HTML

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

CSS

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

'CSS > 애니메이션' 카테고리의 다른 글

애니메이션 05  (2) 2022.09.20
애니메이션 04  (2) 2022.09.20
애니메이션03  (2) 2022.09.03
애니메이션 02  (2) 2022.08.29
애니메이션 01  (3) 2022.08.29

댓글


/
/
/

CSS
광고준비중입니다.