[英]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.