views:

31

answers:

3

On the site I'm currently working on there is a nested unordered list in the sidebar, when an <li> from this list is hovered over, it shows the (previously hidden) child <ul>. This is working fine in all browsers except IE 7+6. In these browsers the popup <ul> displays beneath the <li>'s of the list above. Any idea why it would be doing this?

My CSS is as follows:

div#sidebar-products {
    border-bottom: 3px solid #D31245;
    height: 297px;
}
    div#sidebar-products h2 {
        font-size: 1.5em;
        border-bottom: 0;
        padding: 5px 0 12px 0;
        color: #D31245;
    }
    div#sidebar-products ul{
        z-index: 0;
    }
        div#sidebar-products li{
            position: relative;
        }
            div#sidebar-products ul li a,
            div#sidebar-products ul li a:visited
            {
                display: block;
                border-bottom: 1px solid #eeeeee;
                text-decoration: none;
                padding: 7px 10px 7px 20px;
                color: #6b6869;
                background: #fff url(/img/raquo-red.png) 7px center no-repeat;
            }
            div#sidebar-products li a:hover,
            div#sidebar-products li a:focus,
            div#content-holder div#sidebar-products li.active a
            {
                background-image: url(/img/raquo-white-red.png);
                background-color: #D31245;
                color: #fff;
            }   
        div#sidebar-products ul ul{
            display: none;
            padding-left: 10px;
            position: absolute;
            margin-top: -1px;
            z-index: 9999 !important;
            border: 1px solid #D31245;
            background: #f3f3f3;
            width: 247px;
        }
            div#sidebar-products ul li ul li {
                margin-bottom: 0;
                position: static !important;
                z-index: 500;
            }
                div#site-holder div#content-holder div#sidebar-products ul ul li a {
                    background: #fff url(/img/raquo-red.png) 10px center no-repeat;
                    padding-left: 24px;
                    color: #949494;
                }
                div#site-holder div#content-holder div#sidebar-products ul li ul li a:hover,
                div#site-holder div#content-holder div#sidebar-products ul li ul li a:focus
                {
                color: #D31245;
                background-color: #fff;
            }
+2  A: 

I reckon you have probably encountered the bug that IE doesn't treat z-indexes on a document level, but on a container level. I forget the exact bug details it is usually fixed by adding/removing position: relative to the shared ancestor element I believe.

Try these for some more details:

thehuby
Why thank you! Removing position: relative; was the fix for me.
Probocop
A: 

I think you need to make sure you parent element is position relative, with overflow of auto

sea_1987
A: 

THere's a good article on smashing magazine. It might help you: The Z-Index CSS Property: A Comprehensive Look

Alex Key