box-shadow - HTML CSS CSS Animatable Property

HTML CSS examples for CSS Animatable Property:box-shadow

Introduction

In the following code the box-shadow property of the div element is animating from its initial value "none" to "8px 8px 16px #999", and back to the initial value "none" again up to infinite times.

-webkit- prefix is for Chrome, Safari, Opera.

-moz- prefix is for Firefox.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html lang="en">
 <head>
  <title>Example of CSS3 box-shadow Property Animation</title>
  <style type="text/css">
.box {<!--from w ww  .  j  ava2  s .  com-->
    width: 300px;
    padding: 40px 0;
    font: bold 50px sans-serif;
  text-align: center;
    background: #EEEEEE;
    border: 1px solid red;
    -webkit-animation: test 4s infinite; 
    animation: test 4s infinite;
}

@-webkit-keyframes test {
    50% {box-shadow: 8px 8px 16px #999;}
}

@keyframes test {
    50% {box-shadow: 8px 8px 16px #999;}
}
</style>
 </head>
 <body>

  <p> </p>
  <div class="box">
   Box
  </div>
 </body>
</html>

Related Tutorials