Transform Background image to background colour animation - HTML CSS CSS Animatable Property

HTML CSS examples for CSS Animatable Property:background

Description

Transform Background image to background colour animation

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">

.div1 {<!--from   w w w.  j a  va 2 s  .  c  om-->
   background:url("https://www.java2s.com/style/demo/InternetExplorer.png");
   background-size:cover;
   height:200px;
   width:600px;
   position:relative;
}
.overlay {
   position:absolute;
   width:100%;
   height:100%;
   background:rgba(255, 10, 10, 0);
   -webkit-animation-name: fade;
   -webkit-animation-duration: 10s;
   -webkit-animation-delay: 1s;
   -webkit-animation-timing-function: linear;
   -webkit-animation-iteration-count: infinite;
   -webkit-animation-play-state: running;
   -webkit-animation-direction: alternate;
   -webkit-transform: translateZ(0);
   -webkit-backface-visibility: hidden;
   animation-name: fade;
   animation-duration: 10s;
   animation-delay: 1s;
   animation-timing-function: linear;
   animation-iteration-count: infinite;
   animation-play-state: running;
   animation-direction: alternate;
}
@-webkit-keyframes fade {
   0% {
      background:rgba(255, 10, 10, 0);
   }
   100% {
      background:rgba(255, 10, 10, 1);
   }
}
@keyframes fade {
   0% {
      background:rgba(255, 10, 10, 0);
   }
   100% {
      background:rgba(255, 10, 10, 1);
   }
}


      </style> 
 </head> 
 <body> 
  <div class="div1"> 
   <div class="overlay"></div> 
  </div>  
 </body>
</html>

Related Tutorials