background-size - HTML CSS CSS Animatable Property

HTML CSS examples for CSS Animatable Property:background-size

Introduction

background-size is animated as a length, percentage or calc();

The background image size of the DIV element is animating from its initial value "25%" to "125%", and back to the initial value "25%" 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 background-size Property Animation</title>
  <style type="text/css">
.animated {<!--from  w  ww  .  j av a 2s  .  c  om-->
    width: 300px;
    height: 175px;
    background: url("https://www.java2s.com/style/demo/Opera.png") center lightblue;
    background-size: 25%;
    -webkit-animation: test 4s infinite; 
    animation: test 4s infinite;
}

@-webkit-keyframes test {
    50% {background-size: 125%;}
}

@keyframes test {
    50% {background-size: 125%;}
}
</style>
 </head>
 <body>
  <p> </p>
  <div class="animated"></div>
 </body>
</html>

Related Tutorials