Image Alt&因为Z-index而不显示标题

时间:2012-06-29 08:35:23

标签: html css firefox title alt

这是我的问题,我的HTML中有几个与z-index一起订购的图像。但属性Alt&底部的图像标题不会显示在Firefox& Chrome(IE正常工作......)。 有办法吗?谢谢!

<img src="images/one.png" style="position:absolute;z-index:0;" alt="This one" title="This one"/> 
<img src="images/two.png" style="position:absolute;z-index:1;" alt="" title=""/> 
<img src="images/three.png" style="position:absolute;z-index:2;" alt="" title=""/>

第三张图片(three.png)是覆盖其他两张图片的透明图层。我希望alt是要显示的第一个(one.png)的标题。对不起,解释laq,容易出问题似乎难以解释:)

更新

好的,这是一个制作的脚本:

`$('.animated').each(function(index) {

    var attr = $(this).attr('title');
    if (!attr) {
} else{
        var newId = 'wrapper_' + index;
        $(this).wrap('<div id="' + newId + '"></div>');
        var tit = $(this).attr('title');
        var pst = $(this).css('margin-top');
        var stp = $(this).css('margin-left');
        $('#' + newId).prepend('<div style="position:absolute;z-index:1000;width:' + $(this).width() + 'px;left:50%;top:50%;height:' + $(this).height() + 'px;margin-left:' + stp + ';margin-top:' + pst + ';" title="' + tit + '"></div>');
    }
});`

所以这意味着当图像有标题时,会在其上创建一个带有巨大zindex的div。

1 个答案:

答案 0 :(得分:0)

由于某些原因,我的帖子已删除,请参阅以下内容:

如果透明图像覆盖其他两个,那么alt和title标签将从另外两个顶部的透明层拉出,因为它无法识别下面的其他两个。

如果您希望仅显示第一张图片的标题和替代文字,请将这些值指定给透明图层。

IE可能正在渲染图像的替代文字,其他浏览器在图像存在时不会渲染。