简体   繁体   English

从img的拇指“alt”或“title”属性中提取文本并将其用作放大弹出照片的签名

[英]Extract text from img's thumb “alt” or “title” attribute and use it as a signature for enlarged popup photo

Is it possible to do so?有可能这样做吗? Example: I get image img src="some_img_thumb.png" alt="That's the image alt" title="That's the image title" which is thumbnail and has both alt and title attributes.示例:我得到 image img src="some_img_thumb.png" alt="That's the image alt" title="That's the image title"这是缩略图,同时具有alttitle属性。 When i hover mouse over it or click on it, enlarged image should pop up.当我将 hover 鼠标悬停在它上面或单击它时,应该会弹出放大的图像。 Now, i want make this image pop up with it's alt or title as a signature , placed on bottom img's border.现在,我想让这张图片弹出,它的alt标题作为签名,放在底部 img 的边框上。 I know some other trick ( http://www.dynamicdrive.com/style/csslibrary/item/css-popup-image-viewer ), but i'd like to know if this what i want achieve is possible.我知道其他一些技巧( http://www.dynamicdrive.com/style/csslibrary/item/css-popup-image-viewer ),但我想知道我想要实现的目标是否可行。 I'm sure it's related with this statement:我确定它与此声明有关:

a:after { content: " (" attr(href) ")"; a:after { 内容: " (" attr(href) ")"; } }

but the way i tried to use content: attr(title);但我尝试使用内容的方式:attr(title); statement, was bad way:声明,是不好的方式:

img.thumb:active img.thumb:after { content: attr(title); img.thumb:active img.thumb:after { content: attr(title); font-weight: bold;字体粗细:粗体; margin: 10px 400px 20px 400px;边距:10px 400px 20px 400px; } }

I'm newbie into webdesign and was searching for inspiration to achieve that trick, but still no ideas.我是网页设计的新手,正在寻找实现这一技巧的灵感,但仍然没有想法。

Thanks for eventual help.感谢您的最终帮助。 Cheers干杯

You'd probably want to use jquery for that one.你可能想用 jquery 来做那个。 You can harvest the alt tag, or any other attribute with the following line您可以使用以下行获取 alt 标记或任何其他属性

var altText = $('img').attr('alt');

You'd probably want to use an id on the image as well to make sure you get the right one.您可能还想在图像上使用 id 以确保获得正确的。

Then you can the value to the signature with the following line.然后,您可以使用以下行将值传递给签名。

$('#signature').append(altText);

If you'd like more specific directions comment and I'll be happy to help you further.如果您想要更具体的方向评论,我很乐意为您提供进一步的帮助。

That's the theory, but there are some great lightbox plugins out there that have this functionality.这就是理论,但是有一些很棒的灯箱插件有这个功能。 Have you tried colorbox?你试过彩盒吗?

http://colorpowered.com/colorbox/ http://colorpowered.com/colorbox/

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

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