Html 如何在鼠标悬停时显示工具提示或项目信息?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2992018/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:21:47  来源:igfitidea点击:

how can I display tooltip or item information on mouse over?

htmlmouseover

提问by nectar

I am displaying 5 userImageon one screen.I want to display userIDand emailon mouseoveron those userImage.I used altproperty of image control but that not working in mozila,chrome and some versions of IE. So what are the other better ways to display info on mouseover?

userImage在一个屏幕上显示 5。我想在那些 userImage上显示userID和 显示。我使用了图像控件的属性,但在 mozila、chrome 和某些版本的 IE 中不起作用。那么在鼠标悬停时显示信息的其他更好方法是什么?emailmouseoveralt

回答by Sarfraz

Use the titleattribute while altis important for SEO stuff.

使用title属性 whilealt对 SEO 很重要。

回答by adrianbanks

The simplest way to get tooltips in most browsers is to set some text in the title attribute.

在大多数浏览器中获取工具提示的最简单方法是在title 属性中设置一些文本。

eg.

例如。

<img src="myimage.jpg" alt="a cat" title="My cat sat on a table" />

produces (hover your mouse over the image):

产生(将鼠标悬停在图像上):

a cat http://www.imagechicken.com/uploads/1275939952008633500.jpg

一只猫 http://www.imagechicken.com/uploads/1275939952008633500.jpg

Title attributes can be applied to most HTML elements.

标题属性可以应用于大多数 HTML 元素。

回答by Asaph

The titleattributeworks on most HTML tags and is widely supported by modern browsers.

title属性适用于大多数 HTML 标签,并得到现代浏览器的广泛支持。