当元素位于正常流动之外时,它们可以与其他元素重叠。
的z索引属性指定的元素(其元素应该被放置在的前方或后方,其他)的堆叠顺序。
CSS:
.blue {
background-color: #8EC4D0;
margin-bottom: 15px;
width: 120px;
height: 120px;
color: #FFF;
}
.red {
background-color: #FF4D4D;
position: relative;
width: 120px;
height: 120px;
color: #FFF;
margin-top: -50px;
margin-left: 50px;
}
结果: