CSS drop-down list displayed below the drop-down list, IE6, IE7, absolute positioning error

I ran into one of the craziest problems I've ever encountered in css ...

I have two CSS-jQuery horizontal drop-down lists, one up and one below, displaying a list when I click on it.

The problem occurs when I click on the top drop-down list in IE6 and IE7, and the absolute positioned element moves in relative positions. The top drop-down list (absolute) shows what the drop-down list (relative) looks like below.

JavaScript:

$("button").click(function(e){
    $(".menu").hide();
    $(this).siblings(".menu").show();
    e.stopPropagation()
});
$(document).click(function(){$(".menu").hide()});

HTML:

<div class="top">
    <div class="dropdown">
        <button>Dropdown1 v</button>
        <div class="menu">
            <a href="#link">Option a</a>
            <a href="#link">Option b</a>
            <a href="#link">Option c</a>
        </div>
    </div>
    <div class="dropdown">
        <button>Dropdown2 v</button>
        <div class="menu">
             <a href="#link">Option d</a>
             <a href="#link">Option e</a>
            <a href="#link">Option f</a>
        </div>
    </div>
</div>

CSS

.dropdown{float:left;display:inline;clear:left;position:relative}
.menu{position:absolute;left:0;top:22px;z-index:1}
.menu  a{display:block}

.menu{display:none;border:1px solid #ccc;padding:3px;background:#ffffe0}

Here is an example:

http://jsfiddle.net/AEBaW/

SOLUTION HERE:

http://jsfiddle.net/AEBaW/2/

+3
source share

All Articles