Animation How to - Hover to animate circle to square CSS Button








Question

We would like to know how to hover to animate circle to square CSS Button.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.button {<!--from   w ww . j a va 2s  .c  om-->
  height: 80px;
  width: 80px;
  border-radius: 100%;
  background: red;
  transition: height 0.5s;
  transition: width 0.5s;
  transition: border-radius 1s, box-shadow 1s, background 1s;
  line-height: 75px;
  text-align: center;
  display: inline-block;
  margin: 0;
  box-shadow: 0;
}

.button:hover {
  border-radius: 0%;
  box-shadow: 0px 8px 6px -4px #000000;
  background: #DDD;
  transition: border-radius 0.2s, box-shadow 0.2s, background 0.2s;
}
</style>
</head>
<body>
  <div class="button"></div>
  <div class="button"></div>
  <div class="button"></div>
  <div class="button"></div>
</body>
</html>

The code above is rendered as follows: