找回密码
 立即注册

css3定位,堆叠层级z-index [复制链接]

admin 2025-5-20 15:40:09 120
css3定位,堆叠层级z-index

1.jpg

  1. <title>堆叠顺序-z-index</title>
  2.   <style>
  3.     div {
  4.       position: absolute;
  5.       width: 200px;
  6.       height: 200px;
  7.     }
  8.     .box1 {
  9.       background-color: pink;
  10.       /* 取值是整数,默认是0,取值越大显示顺序越靠上 */
  11.       z-index: 1;
  12.     }
  13.     .box2 {
  14.       background-color: skyblue;
  15.       left: 100px;
  16.       top: 100px;
  17.       z-index: 2;
  18.     }
  19.   </style>
  20. </head>
  21. <body>
  22.   <div class="box1">box1</div>
  23.   <div class="box2">box2</div>
  24. </body>
复制代码


随机推荐

0 回复

发布新话题
搜索
返回顶部