美文网首页
CSS之z-index参数

CSS之z-index参数

作者: 测试探索 | 来源:发表于2022-06-14 20:32 被阅读0次

z-index参数,决定谁在上显示,谁在下显示
index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
<div class="div0">
    <div class="div1"></div>
    <div class="div2"></div>
    <div class="div3"></div>
</div>

</body>
</html>

index.css

div{
    width: 100px;
    height: 100px;
}

.div1{
    background-color: red;
    position: absolute;
    top: 20px;
    left: 100px;
    /*z-index决定谁在前面显示,越大越靠上显示*/
    z-index: 10;

}

.div2{
    background-color: green;
    position: absolute;
    top: 40px;
    left: 120px;
    z-index: 50;

}

.div3{
    background-color: blue;
    position: absolute;
    top: 60px;
    left: 140px;
    z-index: 30;


}

.div0{
    height: 300px;

}
image.png

相关文章

网友评论

      本文标题:CSS之z-index参数

      本文链接:https://www.haomeiwen.com/subject/cyvkmrtx.html