Javascript 在哪里可以找到将标题放置在图像下的自动图像标题脚本
好的,我已经搜索这个脚本很长时间了,似乎有很多脚本将图像标题放在图像的顶部,但没有多少脚本将其直接放在下面(比如维基百科) 我已经找到了一个可以完成这项工作的工具,但是它需要MooTools而不是jQuery,它在Google Chrome中看起来很糟糕,甚至在Internet Explorer中都没有显示。不过,它在Firefox中看起来不错。 所以我想我需要一些人帮我找到这个 脚本的要求:Javascript 在哪里可以找到将标题放置在图像下的自动图像标题脚本,javascript,image,caption,Javascript,Image,Caption,好的,我已经搜索这个脚本很长时间了,似乎有很多脚本将图像标题放在图像的顶部,但没有多少脚本将其直接放在下面(比如维基百科) 我已经找到了一个可以完成这项工作的工具,但是它需要MooTools而不是jQuery,它在Google Chrome中看起来很糟糕,甚至在Internet Explorer中都没有显示。不过,它在Firefox中看起来不错。 所以我想我需要一些人帮我找到这个 脚本的要求: 需要将标题直接放在图像下方,最好放在方框中 应该是跨浏览器兼容的 设置起来相当容易(我对Javasc
- 需要将标题直接放在图像下方,最好放在方框中
- 应该是跨浏览器兼容的
- 设置起来相当容易(我对Javascript了解不多)
- 根据Alt属性自动向图像添加标题
- 根据图像对齐属性定位图像和标题(我使用的是WYSIWYG编辑器)
我想这就够了。如果有人能在这方面提供一些帮助,我将不胜感激,因为我已经花了好几个小时寻找这个 以下是一些jquery插件,您可以使用它们实现图像的标题
我刚刚找到了解决方案!:D 所有的功劳都归于波提拉斯女士
<script src='http://code.jquery.com/jquery-latest.js' type='text/javascript'></script>
<style type='text/css'>
.caption-text { clear:both;color:#666;font-size:90%;text-align:center;margin:0 0 6px;padding:3px 0 0; }
</style>
<script type='text/javascript'>
//<![CDATA[
// Add captions to images from title tag
// by MS-potilas 2012. See http://yabtb.blogspot.com/
function addCaption(img) {
var ele=$(img);
if(ele.parent().is(".caption-wrap")) return;
var title=ele.attr('title');
if(title=="") return;
if(ele.parent().is("a")) ele=ele.parent();
var align=ele.attr("align");
if(!align) align=ele.css("float");
if(align=="") align="none";
var container=ele.wrap('<div style="display:inline-block" class="caption-wrap '+align+'" />').parent();
container.css("float", align);
container.css("width", ele.outerWidth()+"px");
container.css("margin-left", ele.css("margin-left"));
container.css("margin-right", ele.css("margin-right"));
container.css("margin-bottom", ele.css("margin-bottom"));
ele.css("margin-left", "0px");
ele.css("margin-right", "0px");
ele.css("margin-bottom", "0px");
var text=container.append('<p class="caption-text">'+title+'</p>').find(".caption-text");
text.css("width", ele.outerWidth()+"px");
}
// add captions on doc ready to img's with class "caption"
$(document).ready(function() {
$("img.caption").each(function() {
addCaption(this);
});
});
//]]>
</script>
.标题文本{清除:两者;颜色:#666;字体大小:90%;文本对齐:居中;边距:0 0 6px;填充:3px 0;}
//谢谢,但是我已经看过那些了。我正在寻找一个显示标题下的图像,而不是它的顶部。