To create interactive hotspots on an image, you can nest the image and hotspots within a relatively positioned container and then absolutely position the hotspots using percentages:
Style with CSS:
.hotspotted {
position: relative;
}
.hotspot {
display: block;
position: absolute;
}
#hotspot1 {
height: 81%;
left: 9%;
top: 16%;
width: 45%;
}
#hotspot2 {
height: 18%;
right: 11%;
top: 20%;
width: 11%;
}
Markup with HTML:
<div class="hotspotted">
<img height="100%" width="100%" src="img.png"/>
<a href="#" id="hotspot1" class="hotspot"></a>
<a href="#" id="hotspot2" class="hotspot"></a>
</div>
Additional Tip:
If utilizing a map, it's recommended to calculate new coordinates rather than rely solely on percentages. This calculation can be achieved by using the following formula:
new_x = (original_x / original_image_width) * new_image_width
new_y = (original_y / original_image_height) * new_image_height