Animation How to - Animate table cell according to their fluid content








Question

We would like to know how to animate table cell according to their fluid content.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.row, .row div {<!-- w w w. j a  v  a 2  s . co m-->
  -webkit-transition: all .2s linear;
}
.row {
  width: 100%;
  height: 33%;
}
.row:after {
  content: "";
  display: block;
  clear: both;
  height: 0;
}
.row div {
  width: 33%;
  height: 100%;
  float: left;
  box-shadow: inset 0px 0px 0px 2px black;
}

.row:hover {
  height: 66%;
}

.row:hover div {
  width: 16%;
}

.row div:first-child:hover {
  width: 66%;
}

.row div:nth-child(2):hover {
  width: 66%;
}

.row div:nth-child(3):hover {
  width: 66%;
}
</style>
</head>
<body>
  <div class="wrap">
    <div class="row">
      <div></div>
      <div></div>
      <div></div>
    </div>
    <div class="row">
      <div></div>
      <div></div>
      <div></div>
    </div>
    <div class="row">
      <div></div>
      <div></div>
      <div></div>
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: