Animation How to - Change background Overlay with Transitions








Question

We would like to know how to change background Overlay with Transitions.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.overlay {<!-- w  ww. j  av  a 2  s.  co m-->
  background-color: #06C;
  max-width: 400px;
  max-height: 200px;
}

.gallery img {
  transition: opacity 500ms ease-out;
  -webkit-transition: opacity 500ms ease-out;
  -moz-transition: opacity 500ms ease-out;
  -o-transition: opacity 500ms ease-out;
}

.gallery img:hover {
  opacity: 0.5;
}

.gallery li {
  list-style: none;
}
</style>
</head>
<body>
  <ul class="gallery">
    <li>
      <div class="overlay">
        <img src="http://lorempixel.com/400/200/">
      </div>
    </li>
    <li>
      <div class="overlay">
        <img src="http://lorempixel.com/400/200/city">
      </div>
    </li>
    <li>
      <div class="overlay">
        <img src="http://lorempixel.com/400/200/animals">
      </div>
    </li>
  </ul>
</body>
</html>

The code above is rendered as follows: