需要使用具有最高z-index值的选择器
<div style="position: fixed;width: 400px;height: 278px;overflow: hidden;box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 6px;bottom: 0px;transition: transform 2s ease 0s;right: 120px;z-index: 2;" class="Cl"><iframe id="t1dxvk58p7cu" name="t1dxvk58p7cu" class="Xyqxtc" allow="camera" style="height: 100%; width: 100%; background: transparent; overflow: hidden; border: none;"></iframe></div>
<div style="position: fixed;width: 400px;height: 278px;overflow: hidden;box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 6px;bottom: 0px;transition: transform 2s ease 0s;right: 120px;z-index: 3;" class="Cl"><iframe id="t1dxvk58p7cu" name="t1dxvk58p7cu" class="Xyqxtc" allow="camera" style="height: 100%; width: 100%; background: transparent; overflow: hidden; border: none;"></iframe></div>
<div style="position: fixed;width: 400px;height: 278px;overflow: hidden;box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 6px;bottom: 0px;transition: transform 2s ease 0s;right: 120px;z-index: 4;" class="Cl"><iframe id="t1dxvk58p7cu" name="t1dxvk58p7cu" class="Xyqxtc" allow="camera" style="height: 100%; width: 100%; background: transparent; overflow: hidden; border: none;"></iframe></div>
我在下面尝试过但失败了
//div[@class='Cl'][substring-after(@style,'z-index:') > substring-after(../div[@class='Cl']/@style,'z-index:')]
答案 0 :(得分:0)
Here is an XPath 2.0 solution using regex replace
and max
//div[@class='Cl' and replace(@style,'^.*?z-index: (\d+).*?$','$1') = max(../div[@class='Cl']/replace(@style,'^.*?z-index: (\d+).*?$','$1'))]
the main idea is
div[id = max(../div/id)]
这是遵循模式div/[not(..div/id > id)]
的另一个:
//div[@class='Cl' and not(../div[@class='Cl']/replace(@style,'^.*?z-index: (\d+).*?$','$1') > replace(@style,'^.*?z-index: (\d+).*?$','$1'))]
参考文献: