tags:

views:

74

answers:

1

Is it possible to add a hotspot inside a div with a background image?

Many thanks.

Erik

A: 

Yep sure is, just use an absolutely positioned link inside a relatively positioned div (with a background image).

Sample HTML

<div class="hotspot-container">
    <a href="some-href-for-the-hot-spot" class="hotspot">&nbsp</a>
</div>

CSS

.hotspot-container {
  width: 200px; height: 200px;
  position: relative;
  background: url(some-background-image) no-repeat;
}
  .hotspot-container .hotspot {
    width: 10px; height: 10px;
    position: absolute;
    top: 20px; /* Top coord of hotspot (relative to parent, bottom: 20px is also valid) */
    left: 20px; /* Left coord of hotspot (right: 20px is also valid); */
  }
Marko
Many thanks! Works perfect.
Erik
No probs, you can add as many hotspots as you want, and you can control the overlaps using the z-index property (i.e. z-index: 100). The highest z-index will sit on top. Have fun!
Marko