如何CSS实现两个层重叠与显示?

2025-05-21 16:10:47
推荐回答(1个)
回答(1):





test

#father{
position:relative;/*父盒子位置要用relative*/
margin:20px auto;
width:400px;
height:100px;
border:1px solid red;
}
#father #a{
position:absolute;/*子盒子位置要用absolute*/
width:100%;
height:50px;
background:blue;
opacity:0.6;
z-index:2;
}
#father #b{
position:absolute;/*子盒子位置要用absolute*/
width:100%;
height:80px;
background:#F4AF19;
text-align:right;
z-index:1;
}





我是A盒子

    我是B盒子



相关问答
最新问答