<分区>
我的图像的 z-index 有问题。我有一个列表,每个列表项都有一个图像。现在我想让列表项中的图像显示在其他列表项之上。
<li style="position: relative; z-index:9;">
<img src="/" />
</li>
<li style="position: relative; z-index:8;">
<img src="/" style="position: absolute; z-index:999;" />
</li>
<分区>
我的图像的 z-index 有问题。我有一个列表,每个列表项都有一个图像。现在我想让列表项中的图像显示在其他列表项之上。
<li style="position: relative; z-index:9;">
<img src="/" />
</li>
<li style="position: relative; z-index:8;">
<img src="/" style="position: absolute; z-index:999;" />
</li>
最佳答案
z-index
继承自父元素,因此 UL
上的任何 z-index 都将应用于 LI
因此放到 img
上。您必须将位于 LI
顶部的另一个元素与您要覆盖的图像一起使用。
关于html - 具有 z-index 的元素内图像的 z-index,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12087206/