[英]Element with z-index is not hiding elements with lower z-index
這種z-index
格式應該如何工作? 我應該只能看到z-index
為150
的圖層,而不能看到其他任何圖層,但是我可以看到所有三個圖層,因為z-indez
無法正常工作。 應該如何運作?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>z-index</title>
<!--Problem is that the z-index is not at all working-->
</head>
<body >
<!--first div is with highest z-index, it should be on the top layer of the screen-->
<div style=" background-color: #000000 ;height:1000px;width:1000px;z-index:150">
<!--second div is with 100 z-index, it should be on the middle layer of the screen-->
<div style=" background-color: #d0d4db;height:500px;width:500px;z-index:100;">
<!--third div is with 50 z-index, it should be on the lowest layer of the screen-->
<div style=" background-color: #990a0a;height:100px;width:100px;z-index:50;">
</div>
</div>
</div>
</body>
</html>
z-index只能與position: relative;
或position: absolute;
z-index屬性指定元素的堆棧順序。 具有較高堆疊順序的元素始終位於具有較低堆疊順序的元素之前。
注意: z-index僅適用於定位的元素(position:absolute,position:relative或position:fixed)。
我認為您也需要參考此鏈接
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.