如何找出文档中最高的z-index? [英] How can you figure out the highest z-index in your document?

查看:214
本文介绍了如何找出文档中最高的z-index?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了将包含透明文本图像的div设置为文档中的最高z-index,我选择了10,000,它解决了我的问题。



以前我已经猜到了数字3,但它没有效果。



因此,有一个更科学的方法,弄清楚什么z指数高于所有



我尝试在Firebug中找到这个指标,但找不到它。 >解决方案

您可以为特定元素类型(如DIV)调用 findHighestZIndex ,如下所示:

  findHighestZIndex('div');假设 findHighestZindex 函数定义的函数,



this:

  function findHighestZIndex(elem)
{
var elems = document.getElementsByTagName(elem);
var highest = 0;
for(var i = 0; i< elems.length; i ++)
{
var zindex = document.defaultView.getComputedStyle(elems [i],null).getPropertyValue -指数);
if((zindex> highest)&&(zindex!='auto'))
{
highest = zindex;
}
}
return highest;
}


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.

解决方案

You could call findHighestZIndex for a particular element type such as a 'DIV' like this:

findHighestZIndex('div');

assuming a findHighestZindex function that is defined like this:

function findHighestZIndex(elem)
{
  var elems = document.getElementsByTagName(elem);
  var highest = 0;
  for (var i = 0; i < elems.length; i++)
  {
    var zindex=document.defaultView.getComputedStyle(elems[i],null).getPropertyValue("z-index");
    if ((zindex > highest) && (zindex != 'auto'))
    {
      highest = zindex;
    }
  }
  return highest;
}

这篇关于如何找出文档中最高的z-index?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆