HTML Element Style How to - Fly and glow text animation








Question

We would like to know how to fly and glow text animation.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
h1 {<!--from   w w w.j a v  a  2 s .  com-->
  animation:glow 10s ease-in-out infinite;
}
figure {
  animation:wobble 5s ease-in-out infinite;
  transform-origin:center center;
  transform-style:preserve-3d;
}
@keyframes wobble {
  0%,100%{ transform:rotate3d(1,1,0,40deg); }
  25%{ transform:rotate3d(-1,1,0,40deg); }
  50%{ transform:rotate3d(-1,-1,0,40deg); }
  75%{ transform:rotate3d(1,-1,0,40deg); }
}
h1 {
  position:absolute;
}
@keyframes glow {
  0%,100%{ text-shadow:0 0 10px red; }
  25%{ text-shadow:0 0 20px orange; }
  50%{ text-shadow:0 0 10px forestgreen; }
  75%{ text-shadow:0 0 10px cyan; }
}
h1:nth-child(2){ transform:translateZ(5px); }
h1:nth-child(3){ transform:translateZ(10px);}
h1:nth-child(4){ transform:translateZ(15px); }
h1:nth-child(5){ transform:translateZ(20px); }
h1:nth-child(6){ transform:translateZ(25px); }
h1:nth-child(7){ transform:translateZ(30px); }
h1:nth-child(8){ transform:translateZ(35px); }
h1:nth-child(9){ transform:translateZ(40px); }
h1:nth-child(10){ transform:translateZ(45px); }
  </style>
</head>
<body>
  <figure>
  <h1>java2s.com</h1>
  <h1>java2s.com</h1>
  <h1>java2s.com</h1>
</figure>
</body>
</html>

The code above is rendered as follows: