In order to set a div containing a transparent text image as the highest z-index in my document, I picked the number 10,000 and it solved my problem.
Previously I had guessed with the number 3 but it had no effect.
So, is there a more scientific way of figuring out what z-index is higher than that of all of your other elements?
I tried looking for this metric in Firebug but couldn’t find it.
Advertisement
Answer
You could call findHighestZIndex
for a particular element type such as <div>
like this:
JavaScript
x
2
1
findHighestZIndex('div');
2
assuming a findHighestZindex
function that is defined like this:
JavaScript
1
18
18
1
function findHighestZIndex(elem)
2
{
3
var elems = document.getElementsByTagName(elem);
4
var highest = Number.MIN_SAFE_INTEGER || -(Math.pow(2, 53) - 1);
5
for (var i = 0; i < elems.length; i++)
6
{
7
var zindex = Number.parseInt(
8
document.defaultView.getComputedStyle(elems[i], null).getPropertyValue("z-index"),
9
10
10
);
11
if (zindex > highest)
12
{
13
highest = zindex;
14
}
15
}
16
return highest;
17
}
18