jquery - 悬停元素在 IE 7 中显示不正确

标签 jquery css internet-explorer internet-explorer-7 jquery-hover

我正在尝试创建一行图像并在悬停时显示有关商品的更多信息,例如价格和商品链接。现在悬停时,包含更多信息(黄色)的框在 Chrome、Safari、Firefox 和 IE 8 上正确显示。但是,在 IE 7 中,产品图像(蓝色背景)显示在框(黄色)上) 应该显示。解释起来有点困难,请查看链接:http://jsfiddle.net/ryanabennett/bFZDL/27/ .这是成品的样子:http://www.flickr.com/photos/61208628@N07/5937560243/in/photostream .同样,这在 IE 8 和 9 中运行良好,但在 IE 7 中运行良好,我似乎无法弄清楚我遗漏了什么。

这是 HTML:

<div class="productbox">
 <div class="livitem">
  <div class="Livwidgetexpandimg">
   <a href="#"><img src="#" class="popupbox" /></a>
     <div class="popup"></div>
  </div>
 </div>
</div>
<div class="productbox">
 <div class="livitem">
    <div class="Livwidgetexpandimg">
      <a href="#"><img src="#" class="popupbox" /></a>
         <div class="popup"></div>
    </div>
   </div>
</div>

这是 CSS:

.productbox{
float: left;
height: 150px;
margin-left: 5px;
/*overflow: hidden;*/
position:relative;
}

.livitem{
float: left;
position: relative;
top: 3px;
}

.livitem:hover{
background: yellow;
}

.livitem:hover .popupbox {
position:absolute;
top:15px;
left:15px;
z-index:51;
}

.Livwidgetexpandimg{
background: blue;
height: 75px;
margin-left: 10px;
margin-top: 10px;
margin-right: 10px;
padding: 5px;
width: 75px;
float: left;
}

.popupbox{
border: medium none;
height: 75px;
width: 75px;
}

.popup{
background: yellow;
display: none;
float: left;
/*height: 122px;*/
/*margin-left: -10px;*/
opacity: 0;
/*width: 175px;*/
z-index: 50;
height: 106px;
width:230px !important;
position:absolute;
top:0;
left:0;
}

这是 Jquery:

$(function () {
    $('.livitem').each(function () {
        var distance = 10;
        var time = 200;
        var hideDelay = 1;

        var hideDelayTimer = null;

        var beingShown = false;
        var shown = false;
        var trigger = $('.Livwidgetexpandimg', this);
        var info = $('.popup', this).css('opacity', 0);


        $([trigger.get(0), info.get(0)]).mouseover(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            if (beingShown || shown) {
                // don't trigger the animation again
                return;
            } else {
                // reset position of info box
                beingShown = true;

                info.css({
                    top: 10,
                    left: -3,
                    display: 'block'
                }).animate({
                    top: '-=' + distance + 'px',
                    opacity: 1
                }, time, 'swing', function() {
                    beingShown = false;
                    shown = true;
                });
            }

            return false;
        }).mouseout(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            hideDelayTimer = setTimeout(function () {
                hideDelayTimer = null;
                info.animate({
                    top: '-=' + distance + 'px',
                    opacity: 0
                }, time, 'swing', function () {
                    shown = false;
                    info.css('display', 'none');
                });

            }, hideDelay);

            return false;
        });
    });
   });

希望你能帮我解决这个问题。我知道我只是错过了一些小东西,但我似乎无法弄清楚。提前致谢。

最佳答案

IE7 有已知的 z-index 错误,请参阅:IE7 Z-Index issue - Context Menu

在此特定实例中,一种修复方法是添加此 CSS:

.productbox:hover {
    z-index: 9999; /* arbitrary high number */
}

在 IE7 中查看: http://jsfiddle.net/bFZDL/28/

关于jquery - 悬停元素在 IE 7 中显示不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6711771/

相关文章:

html - 为什么此 HTML 中的文本对齐不是动态的?

css - 如何在 Bootstrap 中将文本阴影(或类似的)添加到插入符号?

jquery - $(img).load() 和/或 img.onload=... 中的 img.width 和 img.height 在 IE8 中返回垃圾值

javascript - JQuery 将错误的值附加到变量

PHP CodeIgniter 框架中的 Javascript 可用性验证

php - 使用下拉选择自动填充 PHP 表单中的选择字段

javascript - 用于检查输入是否有任何值的 jQuery 脚本。 IE 和 Chrome 中的问题

javascript - 创建适用于任何选择器的自定义事件

html - 什么时候需要在外部CSS样式开头使用通配符*来初始化或重置所有标签?

jquery - IE 在一个非常简单的菜单中的第一个 LI 之后添加一个垂直空间