相关疑难解决方法(0)

使用z-index将div高于另一个div

我想要在div1上面div2.我尝试z-index但它不起作用.

我试过这段代码:

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

.div1 {
  background: red;
  z-index: 1;
}
.div2 {
  background: blue;
  margin-top: -15vh;
  z-index: 2
}
Run Code Online (Sandbox Code Playgroud)
<div class="div1"></div>
<div class="div2"></div>
Run Code Online (Sandbox Code Playgroud)

html css z-index css3

6
推荐指数
2
解决办法
8380
查看次数

标签 统计

css ×1

css3 ×1

html ×1

z-index ×1