본문 바로가기
CSS

Text animation

by 🐬마뇽뇽 마뇽🦄 2022. 9. 22.
728x90

Text animation

codepen에서 글자들이 하나씩 통통 튀는 애니메이션을 만들었습니다.

01. HTML

html은 간단합니다. h1 에서 글자 수 만큼 span을 만들어 한 글자씩 적어줍니다.

<h1>
  <span>C</span>
  <span>U</span>
  <span>T</span>
  <span>E</span>
  <span>C</span>
  <span>A</span>
  <span>T</span>
  <span>♥</span>
</h1>

02. css

이후에 배경을 지정해주고 원하는 font-family로 지정해준다음, text-shadow로 그림자의 강도를 높여줍니다. 그리고 글자에 animation-delay를 지정해 하나씩 움직이게 만들어줍니다.

html, body {
  width: 100%;
  height: 100%;
  
  background: linear-gradient(140deg, rgb(80, 97, 255) 0%, rgb(54, 7, 131) 100%);
  
  display: flex;
  justify-content: center;
  align-items: center;
}

h1 {
  height: 100px;
}
h1 span {
  font-family: 'VitroCore';
  font-size: 80px;
  color: #fff;
  
  position: relative;
  top: 20px;
  display: inline-block;
  -wedkit-font-smoothing : antialased;
  text-shadow: 0 1px 0 #ccc,
               0 1px 0 #ccc,
               0 3px 0 #ccc,
               0 4px 0 #ccc,
               0 5px 0 #ccc,
               0 6px 0 transparent,
               0 7px 0 transparent,
               0 8px 0 transparent,
               0 9px 0 transparent,
               0 10px 10px rgba(0,0,0,0.4);
  animation: bounse 0.3s ease infinite alternate;
}

h1 span:nth-child(2){ animation-delay:0.1s;}
h1 span:nth-child(3){ animation-delay:0.2s;}
h1 span:nth-child(4){ animation-delay:0.3s;}
h1 span:nth-child(5){ animation-delay:0.4s;}
h1 span:nth-child(6){ animation-delay:0.5s;}
h1 span:nth-child(7){ animation-delay:0.6s;}
h1 span:nth-child(8){ animation-delay:0.7s;}
h1 span:nth-child(9){ animation-delay:0.8s;}

@keyframes bounse {
  100% {
    top: -20px;
    text-shadow : 0 1px 0 #ccc,
               0 1px 0 #ccc,
               0 3px 0 #ccc,
               0 4px 0 #ccc,
               0 5px 0 #ccc,
               0 6px 0 transparent,
               0 7px 0 transparent,
               0 8px 0 transparent,
               0 9px 0 transparent,
               0 50px 20px rgba(0,0,0,0.4);
  }
}

03. 이미지로 한눈에 알아봅시다.

728x90

'CSS' 카테고리의 다른 글

loading Animation  (2) 2022.09.26
box Animation  (2) 2022.09.22
Mouse Hover Effect  (3) 2022.09.20
Wave Animation  (5) 2022.09.19
애니메이션 만들기  (3) 2022.09.08

댓글


고양이 고양이
고양이 고양이
고양이 고양이