jquery - 工具提示未在 Internet Explorer 中正确显示

标签 jquery css internet-explorer tooltip

我在 Internet Explorer 6 和 7 中的工具提示似乎出现在下一个工具提示的“下方”。它可能与 toolTip 类的相对位置样式规则有关,但它是定位 toolTipWrapper 所必需的。下面是我的工具提示的 css 和 Jquery。我正在使用 span 标签并分配一个类 toolTip 并添加一个包含工具提示文本的 title 属性。

CSS:

.toolTip {
    padding-right: 20px;
    background: url(../images/pageElements/help.gif) no-repeat right;
    color: #660099;
    cursor: help;
    position: relative;
}

.toolTipWrapper {
    position: absolute; 
    width: 201px; 
    top: 15px; 
    right: 0px; 
    font-size: 1em; 
    font-weight:bold; 
    color: #fff; 
    display: none; 
    z-index:999!important; 
}  

.tipTop {
    height: 30px;  
    width: 201px; 
    background: url(../images/pageElements/tipTop.png) no-repeat top;
}  

.tipMid {
    background: url(../images/pageElements/tipMiddle.png) repeat-y; padding: 0 25px 0 25px;
}  

.tipBtm {
    background: url(../images/pageElements/tipBottom.png) no-repeat bottom; height: 8px;
}  

JavaScript:

$(function () {
    var zmax = zmax + 1; //increase the z-index by 1
    $(".toolTip").hover(
        function () {
            this.tip = this.title;
            $(this).css('z-index', zmax); //create inline css zindex add 1 layer
            $(this).append(
                '' + '' + '' + this.tip + '' + '' + ''
            );
            this.title = "";
            this.width = $(this).width();
            $(this).find(".toolTipWrapper").css({
                left: this.width - 22
            })
            $(".toolTipWrapper").fadeIn(300);
        },
        function () {
            $(".toolTipWrapper").fadeOut(100);
            $(this).children().remove();
            this.title = this.tip;
        }
    );
});

抱歉,并不是所有的 jQuery 代码都出现在代码括号之间。我尝试添加 jQuery 选项以将工具提示的 Z 索引增加 1,但这似乎不起作用。它不会抛出错误或任何东西,但什么也没有发生。

最佳答案

如果没有实际示例很难确定,所以我可以看到 DOM 结构,但根据我的经验,我发现 IE 和其他浏览器之间不同的 Z-index 问题是计算差异的结果“堆叠上下文”。 (其中“Stacking Context”是您想要搜索和了解的内容)。

关于jquery - 工具提示未在 Internet Explorer 中正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5514071/

相关文章:

jQuery - 当一张卡片悬停或有焦点时,模糊另一张

html - css/html ul 表格行元素水平分布

IE 上的 CSS 视觉错误,带有 wordpress 主题

html - 如何在IE中使div的高度为表格单元格的100%

javascript - 类型错误 : 'undefined' is not a function even when using jQuery. 无冲突

javascript - 简单的双for循环

javascript - 使用 jquery 向左/向右悬停时如何为图像序列设置动画?

html - 垂直居中字段集中的 anchor 标记

html - 小窗口上的未知透明覆盖

internet-explorer - Css:Internet Explorer 的-webkit-border-radius?