注意:

1、z-index的值与大则越近

2、z-index要想生效,必须先定位

3、默认自定义z-index,而不是使用默认的值

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>z-index</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .c1{
            height: 100px;
            width: 100px;
            background-color: brown;
            position: relative;
            z-index: 1000;
        }

        .c2 {
            height: 150px;
            width: 150px;
            background-color: blueviolet;
            position: relative;
            top: -100px;
            z-index: 998;
        }

    </style>
</head>
<body>
<div class="c1"></div>
<div class="c2"></div>
</body>
</html>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2021-12-13
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-14
  • 2022-01-23
  • 2021-11-09
  • 2021-04-21
  • 2021-06-04
  • 2021-06-04
相关资源
相似解决方案