Animation How to - Create glow animation keyframes








Question

We would like to know how to create glow animation keyframes.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
@-webkit-keyframes glow { <!--from   w w w .  java2  s.co  m-->
  0% {opacity: 0;}
  50%{opacity:1;}
  100%{opacity:0;}
}
.glow:after {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.5);
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  content: "";
  border-radius: 3px;
}

#btn {
  -webkit-animation-name: glow;
  -webkit-animation-duration: 1s;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-timing-function: ease-in-out;
  background: red;
  text-align: center;
  font-size: 100px;
  color: white;
  line-height: 100px;
  opacity: 0;
}
</style>
</head>
<body>
  <div id="btn" class="glow">Start</div>
</body>
</html>

The code above is rendered as follows: