简体   繁体   中英

customize alt text of an img tag

To display a hint when my user hovers his mouse over an image <img src="image" alt="product code 000000">

However, the default alt text always displays on the right of my cursor. Is there any way I can move the displayed mini popup to the left of the mouse cursor ???

Update Thank you everyone for your replies.

You mean the yellow tooltip ? You can't. But you can make your own using JavaScript.

The tooltip is the Title element, the alt is the text that appears when the image is not visible. You cannot format the title element, however as has been mentioned you can add in a custom tooltip. I like using the jquery UI tooltips which are easy to get working for a start.

Then you would be able to change the CSS to move it over to the left.

There are tons of javascript tooltip scripts around that can do that for you. By the way, in most browsers the tooltip displays on title="" attribute, not alt.

不,你不能,但你可以使用css和/或javascript创建自己的。

you could create a toolbox in css

img{position:relative;}
img:hover::before{
  content:attr(alt);
  position:absolute;
  left:0;
  top:0;

}

http://www.w3.org/TR/WCAG10-CSS-TECHS/#Alt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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