z-index为子项设置负数,并删除父项上的一组。
.parent {
position: relative;
width: 350px;
height: 150px;
background: red;
border: solid 1px #000;
}
.parent2 {
position: relative;
width: 350px;
height: 40px;
background: red;
border: solid 1px #000;
}
.child {
position: relative;
background-color: blue;
height: 200px;
}
.wrapper {
position: relative;
background: green;
height: 350px;
}
parent 1 parent 1
child child child
parent 2 parent 2
https://jsfiddle.net/uov5h84f/