Effect How to - Hover to create opacity animation








Question

We would like to know how to hover to create opacity animation.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.homepage-box .shadow-layer {<!--   ww  w.j a  v a  2 s.  c om-->
  width: 200px;
  opacity: 1;
  height: 200px;
  background-color: #000;
  transition: opacity 0.8s linear 0s;
}

.homepage-box:hover .shadow-layer {
  opacity: 0.3;
}
</style>
</head>
<body>
  <div class="homepage-box">
    <div class="shadow-layer"></div>
  </div>
</body>
</html>

The code above is rendered as follows: