使用背景图像将热点添加到DIV

时间:2010-08-17 23:37:19

标签: html css

是否可以在带有背景图像的div中添加热点?

非常感谢。

埃里克

1 个答案:

答案 0 :(得分:6)

可以肯定的是,只需在相对定位的div中使用绝对定位的链接(带有背景图像)。

示例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); */
  }
相关问题