Javascript 什么时候不遵守z指数?

Javascript 什么时候不遵守z指数?,javascript,css,google-maps,extjs,google-maps-api-3,Javascript,Css,Google Maps,Extjs,Google Maps Api 3,我正在使用Google maps API v3在Ext中开发一个相当复杂的web应用程序。我有很多带标签的标记(使用MarkerWithLabel类1.1.5版),我使用MarkerManager 问题是我有一类标记(航路点),当其他标记重叠时,我希望这些标记位于它们后面 我尝试将z索引强制降到其他标记的下方,根据Firebug DOM检查器,我成功了。然而,他们仍然出现在前面。在FF和Chrome中也是如此(我不需要测试其他浏览器) 我仔细阅读了DOM查看器生成的HTML。奇怪的是Firebu

我正在使用Google maps API v3在Ext中开发一个相当复杂的web应用程序。我有很多带标签的标记(使用MarkerWithLabel类1.1.5版),我使用MarkerManager

问题是我有一类标记(航路点),当其他标记重叠时,我希望这些标记位于它们后面

我尝试将z索引强制降到其他标记的下方,根据Firebug DOM检查器,我成功了。然而,他们仍然出现在前面。在FF和Chrome中也是如此(我不需要测试其他浏览器)

我仔细阅读了DOM查看器生成的HTML。奇怪的是Firebug显示的相关节点已经褪色,就好像它们被隐藏了一样,但事实并非如此

从DOM检查器复制并粘贴以下内容(删除标识信息)。航路点标记为z指数为100/101的标记

<div style="z-index: 105; position: absolute; left: 0px; top: 0px;">
<div class="markerselected" style="position: absolute; overflow: hidden; opacity: 0.01; margin-left: 2px; margin-top: 2px; left: 554px; top: 271px; z-index: 1000001; display: block;" onselectstart="return false;" ondragstart="return false;"  >aaaaa</div>
<div class="markerLabel" style="position: absolute; overflow: hidden; opacity: 0.01; margin-left: 2px; margin-top: 2px; left: 565px; top: 279px; z-index: 280; display: block;" onselectstart="return false;" ondragstart="return false;"  >bbbbb</div>
<div class="markerLabel" style="position: absolute; overflow: hidden; opacity: 0.01; margin-left: 2px; margin-top: 2px; left: 544px; top: 277px; z-index: 278; display: block;" onselectstart="return false;" ondragstart="return false;"  >ccccc</div>
<div class="markerLabelWP" style="position: absolute; overflow: hidden; opacity: 0.01; margin-left: 2px; margin-top: 2px; left: 570px; top: 259px; z-index: 101; display: none;" onselectstart="return false;" ondragstart="return false;"  >aaaaaa</div>
<div class="gmnoprint" style="width: 30px; height: 30px; overflow: hidden; position: absolute; left: 535px; top: 235px; z-index: 265; opacity: 0.01; cursor: pointer;" >
<div class="gmnoprint" style="width: 30px; height: 30px; overflow: hidden; position: absolute; left: 539px; top: 241px; z-index: 1000000; opacity: 0.01; cursor: pointer;" >
<div class="gmnoprint" style="width: 30px; height: 30px; overflow: hidden; position: absolute; left: 550px; top: 249px; z-index: 279; opacity: 0.01; cursor: pointer;" >
<div class="gmnoprint" style="width: 30px; height: 30px; overflow: hidden; position: absolute; left: 529px; top: 247px; z-index: 277; opacity: 0.01; cursor: pointer;" >
<div class="gmnoprint" style="width: 32px; height: 32px; overflow: hidden; position: absolute; left: 554px; top: 227px; z-index: 100; opacity: 0.01; cursor: pointer;" >
</div>

AAAA
bbbbb
ccccc
AAAAA

写下这一切给了我一些想法,但我仍然没有解决它。我想知道是否所有嵌套的div都有自己的z-index是问题所在???

为了更好地理解z-index:(里面的7个链接)

Pete,我还不时地用
z-index
,但它似乎不起作用


在元素中添加
float
position
时,问题基本上得到了解决。由于您可能不想使用
float
,因此应该使用一个简单的
位置:relative

z-index 105上的容器,其中包含各种z-index上的内容。因此,子对象从父对象的参数上反弹。

PS外观不正确的嵌套只是因为dom检查器复制/粘贴的方式解决了问题:问题出现了,显然是因为重要标记上的图标由两部分组成,标记和阴影。航路点只是一个标记,因此无论我如何更改z索引,它都会遮挡主要标记的阴影部分。因此,我使航路点标记透明,并使用阴影作为“pin”。这个给我修好了。我仍然无法解释z指数现象,但它现在起作用了,所以我不在乎!谢谢赫尔穆特。对于其他有此问题的人,请务必区分图像和BG图像,因为地图和标记由许多部分组成!谢谢金鹏先生。我不确定这是不是解决办法。阅读上面发布的Rustam链接。