简体   繁体   English

将鼠标悬停在图像部件上可显示提示

[英]Mouse hover on image parts show hints

I have an html page with simple, static image like this : Image 我有这样的简单,静态图片的HTML页面图片

I need a way that putting mouse (hover) on any object, for example - "BED" to get a tooltip that - "There is bed". 我需要一种将鼠标悬停在任何对象上的方法,例如-“ BED”以得到一个工具提示-“有床”。

I know how hover works at pure html, with blocks or any teg, but I need a way of doing/tracking the user cursor, and when it enters in specific zone, to show the hint. 我知道将鼠标悬停在纯HTML上(带有块或任何teg)是如何工作的,但是我需要一种做/跟踪用户光标的方法,以及当它进入特定区域时显示提示的方法。 Probably some JS required. 可能需要一些JS。 How can I setup this unknown geometric forms with their coordinates to achieve my goal? 如何设置未知的几何形状及其坐标以实现我的目标?

No JS script needed :) 不需要JS脚本:)

You can use image maps .. they are old but should work as you expected.. you can run it and see title when you hover over kitchen and bad 您可以使用图像地图..它们很旧,但是应该可以按预期工作。.您可以运行它并在将鼠标悬停在厨房上并且坏了时看到标题

I used this webpage to 'generate' rectangles and area over the image or hotsports.. 我使用网页来“生成”图像或热门运动上的矩形和区域。

 <img src="https://www.edrawsoft.com/symbols/simple-home-floorplan.png" usemap="#image-map"> <map name="image-map"> <area target="" alt="This is bad" title="This is bad" href="" coords="520,132,451,48" shape="rect"> <area target="" alt="This is kitchen" title="This is kitchen" href="" coords="343,204,254,55" shape="rect"> </map> 

In addition of the prev answer you can also add this jQuery to your page. 除了上一个答案外,您还可以将此jQuery添加到您的页面中。 It makes the tooltip show more prominent and also quicker: 它使工具提示显示得更加突出并且也更快:

$( function() {
  $( document ).tooltip();
} );

This native jQuery function uses the 'title' attribute! 这个本地的jQuery函数使用'title'属性! Don't forget to add these like this: 不要忘了像这样添加这些:

<img title='This is a test!!' src='test.png'>

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

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