我正在使用Google maps API v3在Ext中开发一个非常复杂的Web应用程序。我有很多带标签的标记(使用MarkerWithLabel 1.1.5版本),我使用MarkerManager。
问题是我有一类标记(航路点),当它们重叠时,我想要在之后我的其他标记。
我试图将z-index强制降低到其他标记之下,并且根据Firebug DOM检查器,我已经成功了。但是,他们仍然出现在前面。这在FF和Chrome中都是如此(我不需要测试其他浏览器)。
我已经仔细研究过DOM查看器生成的HTML。奇怪的是,Firebug显示相关节点褪色,好像它们被隐藏了,但它们不是。
从DOM检查器复制并粘贴以下内容(删除标识信息)。航点标记是z-index 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>
写出所有这些给了我一些想法,但我还没有解决它。我想知道所有带有z索引的嵌套div是否都是问题?
答案 0 :(得分:4)
皮特,我还不时地用z-index
捣乱,但它似乎没有用。
此问题主要是在向元素添加float
或position
时解决的。由于您可能不想使用float
,因此应该使用简单的position:relative
...
答案 1 :(得分:2)
为了更好地理解z-index:https://developer.mozilla.org/en/Understanding_CSS_z-index(内部有7个链接)
答案 2 :(得分:0)
z-index 105上的容器,其中包含各种z-index的内容。所以孩子们正在逃避父母的准备。