Page Widget How to - Scale Background Image on Hover








Question

We would like to know how to scale Background Image on Hover.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.frame {<!--from  ww  w .  j  a  va  2  s  .  c  om-->
  width: 200px;
  height: 100px;
  overflow: hidden;
}
.frame>i {
  display: block;
  background-image:url("http://placehold.it/200x200");
  background-position: center center;
  width: 200px;
  height: 100px;
  transition: all .2s ease-in;
}

i:hover {
  -webkit-transform: scale(1.5);
  transform: scale(1.5);
  background-position: center -90px;
  cursor: pointer;
}
</style>
</head>
<body>
  <div class="frame">
    <i></i>
  </div>
</body>
</html>

The code above is rendered as follows: