flex-grow - HTML CSS CSS Animatable Property

HTML CSS examples for CSS Animatable Property:flex-grow

Introduction

In the following code the flex-grow property of the flex item2 is animating from its initial value "1" to "4", and back to the initial value "1" 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 flex-grow Property Animation</title>
  <style type="text/css">
.flex-container {<!--from  ww  w . j  av  a 2 s.c  om-->
  width: 300px;
  height: 200px;
  font-size: 32px;
  border: 1px solid black;
  display: -webkit-flex; /* Safari */
  display: flex; 
}
.flex-container div {
  -webkit-flex-grow: 1; /* Safari */
    -ms-flex-grow: 1; /* IE 10 */
      flex-grow: 1; 
}
.item1 {
  background: #e84d51;
}
.item2 {
  background: #7ed636;
}
.item3 {
  background: #2f97ff;
}
.animated {
    -webkit-animation: test 4s infinite; 
    animation: test 4s infinite;
}

@-webkit-keyframes test {
    50% {-webkit-flex-grow: 4;}
}

@keyframes test {
    50% {flex-grow: 4;}
}
</style>
 </head>
 <body>

  <p> </p>
  <div class="flex-container">
   <div class="item1">
    1
   </div>
   <div class="item2 animated">
    2
   </div>
   <div class="item3">
    3
   </div>
  </div>
 </body>
</html>

Related Tutorials