简体   繁体   English

ie6&7 z-index问题

[英]ie6&7 z-index problem

I'm having a bit of difficulty with css z-index property in ie 6 & 7. I've got a list of "boxes" with a popup div appearing when you roll over the "box" (using jquery) but in ie6 & 7 the popup appears under the box below. 我在css z-index属性中遇到了一些困难,即6和7.我有一个“盒子”列表,当你滚动“盒子”(使用jquery)时会出现一个弹出式div,但是在ie6中&7弹出窗口显示在下面的框下方。 Could someone tell me what I'm doing wrong and why? 有人能告诉我我做错了什么,为什么? Here's my css: 这是我的css:

#trainingModules
        {
            width: 250px;
            height: auto;
            padding: 0;
            margin: 0;    
            font-family: Arial;
        }

        #trainingModules li
        {
            list-style: none;
            float: left;
            position: relative;
            width: 200px;
            height: 180px;
            margin: 5px 15px 10px 15px;
            cursor: pointer;
        }
        #trainingModules li .mod
        {
            width: 100%;
            height: 100%;
            z-index: 0;
        }
        #trainingModules .modTitle  { width: 100%; height: 32px;}
        #trainingModules .modBody
        {
            border: 4px solid #e5e5e5;
            width: 192px;
            height: 132px;  
            position:relative; 
        }
        #trainingModules .mod .modBody .bestScore  
        {
            font-size: 20px;
            color: red;
            position: absolute;
            top: 5px;
            left: 5px;
        }
        #trainingModules .mod .modBody .bestScore span { 
            font-size: 10px; 
            line-height:20px; 
            vertical-align: top; 
        }
        #trainingModules .modBody .moduleDescription 
        {
            position:absolute;
            top: 132px;
            left: -4px;
            color:White;
            background-color: Black;
            z-index: 100;
            width: 190px;
            padding: 5px;
        }

My jQuery: 我的jQuery:

$(document).ready(function() {
        $('#trainingModules li').hover(function () {
                $(this).find('.moduleDescription').show();
            },
            function () {
                $(this).find('.moduleDescription').hide();
            });
  });

My html: 我的HTML:

<ul id="trainingModules">

    <li>
        <div class="mod">
            <div class="modTitle">
                <div class="stateIcon"></div>
                <a class="moduleLaunchLink" href="somelink">Some Name</a>
            </div>
            <div class="modBody">
                <div class="bestScore">93<span>%</span></div>
                <div class="moduleDescription" style="display:none;">
                    blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
                    blah blah blah blah blah blah blahblah blah blah blah blah blah blah blah blah
                </div>
            </div>
        </div>
    </li>

    <li>
        <div class="mod">
            <div class="modTitle">
                <div class="stateIcon"></div>
                <a class="moduleLaunchLink" href="somelink">Some Name</a>
            </div>
            <div class="modBody">
                <div class="bestScore">93<span>%</span></div>
                <div class="moduleDescription" style="display:none;">
                    blah blah blah blah blah blah blah blah blah blah blah blah blah blah 
                    blah blah blah blah blah blah blahblah blah blah blah blah blah blah blah blah
                </div>
            </div>
        </div>
    </li>

</ul>

Thanks. 谢谢。

IE's z-index issues can usually be resolved by messing around with setting position:relative (or position:absolute ) on the affected element and its parents. IE的z-index问题通常可以通过在受影响的元素及其父元素上设置position:relative (或position:absolute )来解决。

(Generally you'd use position:relative ; if you actually want to position stuff absolutely, you'd already have specified it) (通常你会使用position:relative ;如果你真的想要绝对定位东西,你已经指定了它)

It's a fairly well known issue; 这是一个众所周知的问题; there's lots of sites with details of how to work around it. 这里有很多网站,详细介绍了如何解决这个问题。

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

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