<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>不同堆叠上下文元素排列顺序</title>
<style type="text/css">
/* 可见,.box1的p元素没有层叠掉.box2的p元素 */
html {
background: skyblue;
}
.box1 {
/* 层叠上下文元素 */
width: 200px;
height: 200px;
background-color: darkcyan;
position: relative;
z-index: 1;
}
.box2 {
/* 层叠上下文元素 */
width: 200px;
height: 200px;
background: hotpink;
position: relative;
z-index: 2;
}
.box3 {
width: 200px;
height: 200px;
background-color: greenyellow;
}
/* .box1 p > .box2 p */
.box1 p {
width: 100px;
height: 100px;
position: absolute;
background-color: khaki;
z-index: 999;
}
.box2 p {
width: 100px;
height: 100px;
position: absolute;
background-color: lawngreen;
z-index: -999;
}
</style>
</head>
<body>
<div class="box1">
<p>文字1</p>
</div>
<div class="box2">
<p>文字2</p>
</div>
<!-- <div class="box3">
<p></p>
</div> -->
</body>
</html>
538 不同堆叠上下文元素排列顺序
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
进程上下文VS中断上下文
内核态),这个级下所有的操作都受系统信任,而应用程序运行在较
中断上下文 中断处理 进程上下文 -
Android 协程上下文的元素。上下文的继承 异常处理
上下文的公式=默认值+继承的CoroutineContext+参数。有时候我们需要定义多个元\
android Test 子类 操作符