html的z-index
转载vscode编辑
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.shadow{
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color:rgba(0,0,0,0.5);
z-index: 80;
}
.mode{
position: fixed;
height: 400px;
width: 400px;
background-color: white;
z-index: 100; /*数值越大,越在上层显示*/
left: 50%; /*按照窗口宽度的50%来移动*/
top: 50%; /*按照窗口高度的50%来移动*/
margin-top: -200px;
margin-left: -200px;/*正的相当于距离左边200px,负号相当于右边了 */
}
</style>
</head>
<body>
<div>
<h1>
我在测试
</h1>
</div>
<div class="mode"></div>
<div class="shadow"></div>
</body>
</html>
本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Z-INDEX: 999
z-index 属性设置元素的堆叠顺序:拥有更高堆叠顺序的元素总是会处于堆叠顺序较低的元素的前面。所以,Z-INDEX: 99
css html javascript 优先级 css样式 -
z-index详解
z-index 属性设置元素的堆叠顺序。拥有更高堆叠顺序的元素总是会处于堆叠顺序较低的元素的前面。
类目 子节点 文档流 css3 html -
z-index取值范围
CSS: z-index 取值范围原理:当两个同父元素z-index相同时,后面的元素显示在上面。n, d2.z-index = min
z-index取值范围 css z-index chrome 背景色