HTML Element Style How to - Mark image hotspot with hover effect








Question

We would like to know how to mark image hotspot with hover effect.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#myImage {<!-- w w  w .j a v a2s  .c  om-->
  background-image:url(http://placehold.it/400x400);
  width: 640px;
  height: 457px;
  position: relative;
}

#myImage a {
  border: 1px solid #fff;
  width: 50px;
  height: 50px;
  display: block;
  position: absolute;
  background-color: rgba(255, 255, 255, 0.1);
}

#myImage a:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

#myImage_zone1 {
  top: 350px;
  left: 350px;
}

#myImage_zone2 {
  top: 150px;
  left: 200px;
}

#myImage_zone3 {
  top: 280px;
  left: 100px;
}
</style>
</head>
<body>
  <div id="myImage">
    <a id="myImage_zone1" href="http://java2s.com"></a> 
    <a id="myImage_zone2" href="http://java2s.com"></a> 
    <a id="myImage_zone3" href="http://java2s.com"></a>
  </div>
</body>
</html>

The code above is rendered as follows: