Craig Lafferty
Craig Lafferty

Reputation: 791

IE 10 not respecting z-index

I have a div with fixed size and position relative on my page. (I unfortunately am not allowed to share this code so bear with me if you can). I wanted to to have a disabled input become re-enabled when double clicked but as you may know disabled inputs don't like to fire click events. I came up with a solution which involves putting an input absolutely positioned inside of the relatively positioned container along with an absolutely positioned div with the same dimensions and position. When double clicking I change the div's display to none. This works beautifully in other browsers but IE 10 (I haven't checked lower versions) doesn't respect the z-indexes that I have placed on the div and input. The div has a z-index of 2 and the input has a z-index of 1 but IE ignores this and allows me to click "through" the div and into the input as if the div weren't there. I'm not asking for anyone to debug my code as I can't show it but I would appreciate any known workarounds for this if it's a common problem/bug.

Upvotes: 1

Views: 3250

Answers (2)

davidcondrey
davidcondrey

Reputation: 35983

Add this:

 <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 

And make sure your doctype is set

<!doctype html>

Upvotes: 1

Adrian Preuss
Adrian Preuss

Reputation: 3113

Internet-Explorer is very tricky particularly with z-index and positions.

Okay, whats the Solution? Hard work. Be sure that elements are mostly have an position. Must in some places work with position: relative;.

To address the problem with the z-index, you must go from the highest parent (<html>) up to all childs and set each child a z-index (started with 0), increase each z-index, example:

html {
    z-index:    0;
}

body {
    z-index:    1;
}

header {
    z-index:    2;
}

header nav {
    z-index:    3;
}

Generally, check the validity: HTML Validator, CSS Validator

Upvotes: 6

Related Questions