HTML Element Style How to - Create Div background-color css class fade effect








Question

We would like to know how to create Div background-color css class fade effect.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.my-bkgr {<!-- www  .jav a  2s .  co  m-->
  background-color: #ECF0F1;
  transition: all 3s ease-out;
  width: 100px;
  height: 100px;
}

.my-bkgr:hover {
  background-color: #E74C3C;
}
</style>
</head>
<body>
  <div class="my-bkgr"></div>
</body>
</html>

The code above is rendered as follows: