html - 如何将对象附加到图像上的固定位置?

标签 html css image position

到现在为止,我只是想出了如何使用页面坐标将对象放置到固定位置。
这是问题所在:

当我向上/向下/向左/向右移动图像(对象是图像上您可以点击的点)时,这些点停留在旧位置。

那么有没有办法从图像中给他们坐标呢?然后我可以四处移动 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>

最佳答案

改变位置属性:

div.point{
    position: relative;
}

这意味着点对象的像素位置是相对于父容器(在本例中是您的图像)。

This article很好地解决了定位问题。

关于html - 如何将对象附加到图像上的固定位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25674807/

相关文章:

html - CSS - 如何设置标题图像作为使用例如。 Facebook?

ios - 将解析图像下载到数组中,然后将它们附加到另一个数组中

html - HTML 中的数学运算

php - 将文本框值存储在 php 数组中

css - 如何使此内容 div 达到可用高度的 100%?

jQuery 移动显示加载器用于自定义加载过程?

css - 网页源似乎链接到不同的 CSS 样式表

css - 无法在 div 中的另一个图像上显示图像

javascript - 增加输入标签内的 ID 属性

c++ - 在一个 QGraphicsView 中显示两个图像