简体   繁体   English

CSS 或 HTML:链接或锚定到图像坐标

[英]CSS or HTML: Link or Anchor to Image Coordinates

What I am trying to do is similar to an image map - in reverse.我想做的是类似于图像映射 - 反过来。 I have a large image (over 2000x2000) and want to give links to coordinates on the image.我有一个大图像(超过 2000x2000)并且想提供图像坐标的链接。 There are items in the image that I would like users to be able to jump directly to with having to scan over the whole image manually.我希望用户能够直接跳转到图像中的某些项目,而不必手动扫描整个图像。 Is this possible with either CSS or HTML by adding links to coordinates or adding anchors to the image?通过向坐标添加链接或向图像添加锚点,CSS 或 HTML 是否可以实现这一点? I would use js if that was an option as well.如果那也是一种选择,我会使用 js。

Interesting.有趣的。 The notion of jumping to a position on a web browser window is limited in general.跳转到 Web 浏览器窗口上的某个位置的概念通常是有限的。 Here are some general possibilities, without specific implementation details:以下是一些通用的可能性,没有具体的实现细节:

  1. You could treat it as a sprite image, and use JavaScript/jQuery to change the image coordinates so that the point of the image you are interested in moves to the the top left of a div positioned on the page.您可以将其视为精灵图像,并使用 JavaScript/jQuery 更改图像坐标,以便您感兴趣的图像点移动到页面上 div 的左上角。 But the portion of the image above and to the left of that point would not be visible.但是该点上方和左侧的图像部分将不可见。

  2. You could define it as a background image in a div, and define an invisible table or invisible fixed-position divs within that div, and link to specific divs or cells in that overlay.您可以将其定义为 div 中的背景图像,并在该 div 中定义一个不可见的表格或不可见的固定位置 div,并链接到该叠加层中的特定 div 或单元格。 In this case, a y-coordinate in the image where the div or cell is positioned would probably move to the top of the browser window, but horizontal positioning would be problematic.在这种情况下,图像中 div 或单元格所在的 y 坐标可能会移动到浏览器窗口的顶部,但水平定位会出现问题。 If the div or cell you target is off the screen to the right or left, the page would shift to expose it, but I don't thing that you could guarantee where the specific x-coordinate would be positioned.如果您定位的 div 或单元格在屏幕的右侧或左侧,页面会移动以显示它,但我不认为您可以保证特定 x 坐标的位置。 Also, if the target is near the bottom of the web page, that target point will not move to the top.此外,如果目标靠近网页底部,则该目标点不会移动到顶部。 But this solution wouldn't require JavaScript/jQuery - it would just mean linking to element ID's on the page.但是这个解决方案不需要 JavaScript/jQuery - 它只是意味着链接到页面上的元素 ID。

  3. This is almost the same as #2... You could overlay the image with divs and/or a table at higher z-levels, and link to those divs or table cells.这与#2 几乎相同...您可以使用 div 和/或更高 z 级别的表格覆盖图像,并链接到这些 div 或表格单元格。

  4. You could use JavaScript/jQuery to position a fixed-size div with visible borders so that its upper-left corner is at the position in the image that you are interested in. I think you'd still have to link to that div in order to make sure that it is visible in the current viewport.您可以使用 JavaScript/jQuery 定位具有可见边框的固定大小的 div,使其左上角位于您感兴趣的图像位置。我认为您仍然必须按顺序链接到该 div以确保它在当前视口中可见。

  5. You should be able to lay out a form over the image and move the cursor to fields on the form.您应该能够在图像上布置表单并将光标移动到表单上的字段。 I think that the form could be transparent so that the cursor appears to be moving around on the image.我认为表单可以是透明的,以便光标在图像上移动。 But you'd need be confident that the data entry cursor is sufficiently visible on top of the image to be useful.但是您需要确信数据输入光标在图像顶部足够可见才能有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM