Page Widget How to - Hover to add background image








Question

We would like to know how to hover to add background image.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div.open {<!--from w ww  .  ja va  2  s .c om-->
  background: none;
  border: 1px solid black;
  width: 137px;
  height: 49px;
}

div.open:hover {
  background:url('http://www.java2s.com/style/download.png');
}
</style>
</head>
<body>
  <div class="open"></div>
</body>
</html>

The code above is rendered as follows: