2014-09-04 59 views
0

到目前为止,我只想出如何将对象放置到页面坐标的固定位置。
这里是问题:如何将对象附加到图像上的固定位置?

当我移动图像(对象是你可以点击的图像上的点)向上/向下/向左/向右时,点位于旧位置。

那么有没有办法让他们从图像的坐标?然后我可以移动img,点数将保持在原来的位置,对吗?

这是我的观点(CSS):

div.point { 
    border-radius: 50%; 
    width: 28px; 
    height: 28px; 
    background: #7ab51d; 
    border: 3px solid white; 
    position: fixed; 
    z-index:1000; 
    cursor: pointer; 
} 

这些我怎么定位他们:

<div id="Restroom_Water" class="point" style="top:380px;left:1000px;" onmouseover="$('#Restroom_text_Water').show();" onmouseout="$('#Restroom_text_Water').hide();"></div> 

回答

1

改变位置属性:

div.point{ 
    position: relative; 
} 

这意味着的像素位置点对象是相对于父容器(在这种情况下是您的图像)。

This article重新定位很好。

+0

所以我需要把点放在与img相同的容器中吗? – 2014-09-04 21:09:48

+0

正确。该容器是固定的,但点是相对的。这里是一个小提琴:http://jsfiddle.net/gfuh2pf0/ – Quoendithas 2014-09-04 21:19:55

+0

非常感谢! :-) – 2014-09-04 21:22:47

相关问题