This is the lighter side of we love... opinions, news, fun stuff, our friends and partners. Enjoy, comment and spread the love...

« back to blog

IE6 Select element always on top

As more and more javascript and AJAX are used IE6s incompetencies are increasingly becoming apparent. It really is getting on now. This is especially the case with transparencies and overlays.

The latest that we’ve been running into here quite a bit lately (as the designers use more and more modal windows) is the fact that whatever z-index trickery you try and perform, a select box will always display above any intersecting elements. You can see an example below:

Quite ugly, non? After a bit of digging around a while back we found the official reasoning:

Windowed controls in IE will always cover DHTML layers. That means if you have a DIV that pops up or floats on the page and it intersects with a windowed control (such as the common SELECT box), the windowed control will obscure the DIV, no matter what zIndex you have set for each element. The problem is based on the historical fact that form fields have typically been rendered by the operating system/windowing system, where everything else on the page is rendered by the browser.

Luckily there’s a relatively simple way to solve this – IFRAMES. Not only are they good for cross domain AJAX requests, they save us here again by their ability to exist in the z-index for both page controls and windowed controls at the same time. Simply placing an iframe element behind (and inbetween in the z-index) your modal / overlay will block the windowed controls from view, like so:

Remarkably simply, setting the iframes opacity will also still block out the windowed controls underneath.

iframe.style.filter=’progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)’;

So you can have any kind of transparent elements in your overlay.

2 Comments »

2 Responses to “IE6 Select element always on top”

  1. ladyAnne Says:

    I’ve just come across your post. Aghhhh i’ve been trying to get this to work for quite some time and finally i think i found the answer.

    I’m a novice with css and would like to see an example of the markup pls.

    I have a form dropdown box and a navigation bar which is showing behind when the nav slides out. Its showing up perfectly in IE7, IE8, Chrome, FireFox and Opera but for the life of me i can’t get it to work on IE6!!!!!

    Would you be so kind as to post your markup of the iframe [i have never used one before]

    Here is my css
    #SortBox {
    text-align: right;
    margin-bottom:3px;
    width: 145px;
    height:27px;
    float: right;
    background-color:red; }

    #SortBox .textbox {
    float: left;
    width: 60px;
    height:19px;
    position:relative;
    margin: 4px 0px 0px 0px;
    background-color:green; }

    this is my html

    {LANG_NAME}
    {LANG_PRICE}

    I need to send this *sortBox* back so the navigation bar can be on top when it slides out.

    Hope i’m making sense!

    Thanks
    ladyAnne

  2. ladyAnne Says:

    that html did not show up correctly ooops

    here it is

    {LANG_NAME}
    {LANG_PRICE}

Leave a Reply