Animation Text using HTML and CSS

Hello Coders,

Today we will learn to code text animation

HTML Code:

<!DOCTYPE html>
<html lang="en">
  <!--www.codeithub.com-->
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Codeithub | codeithub.com</title>
    <link rel="stylesheet" href="main.css">
</head>
<body>
  <div>
    <p>C</p>
    <p>o</p>
    <p>d</p>
    <p>e</p>
    <p>i</p>
    <p>t</p>
    <p>h</p>
    <p>u</p>
    <p>b</p>
  </div>
</body>
</html>

CSS Code:

:root {
  --effect: hover 5s linear infinite;
}
*{
   margin:0;
}

body {
  display: flex;
  width: 100vw;
  height: 100vh;
  background: #1d1818;
  align-items: center;
  justify-content: center;
}

div {
  text-align: center;
}

p {
  display: inline-block;
  text-transform: uppercase;
  text-align: center;
  font-size: 4em;
  font-family: arial;
  font-weight: 600;
  transform: scale(.5);
  color: #121212;
  -webkit-text-stroke: 2px gray;
}

p:nth-child(1) {
  animation: var(--effect);
}

p:nth-child(2) {
  animation: var(--effect) .125s;
}

p:nth-child(3) {
  animation: var(--effect) .25s;
}

p:nth-child(4) {
  animation: var(--effect) .375s;
}

p:nth-child(5) {
  animation: var(--effect) .5s;
}

p:nth-child(6) {
  animation: var(--effect) .675s;
}

p:nth-child(7) {
  animation: var(--effect) .75s;
}
p:nth-child(8) {
  animation: var(--effect) .85s;
}
p:nth-child(9) {
  animation: var(--effect) .95s;
}
@keyframes hover {
  0% {
    transform: scale(.5);
    color: #121212;
    -webkit-text-stroke: 2px gray;
  }

  20% {
    transform: scale(1);
    color: pink;
    -webkit-text-stroke: 3px red;
    filter: drop-shadow(0 0 1px black)drop-shadow(0 0 1px black)drop-shadow(0 0 3px red)drop-shadow(0 0 5px red)hue-rotate(10turn);
  }

  50% {
    transform: scale(.5);
    color: #121212;
    -webkit-text-stroke: 2px gray;
  }


}

OUTPUT

See also  12 Awesome Pure CSS Spinners - loaderskit

Leave a Reply

Your email address will not be published. Required fields are marked *