div+css怎样才能实现DIV遮挡的效果?

2025-02-27 12:47:32
推荐回答(4个)
回答1:

就是借位,也就是设置边距的大小,设一个负数就能实现。
但是也可以用别的方法,做成这个效果,而不是真的挡住。

回答2:

用定位,例:



css:
.top{width:300px; height:100px; background:#000;}
.bottom{width:300px; height:100px; background:#090; position:relative; left:50px; top:-50px;}
你把代码粘到相对应的文件中看看效果就知道了

回答3:






.top,.bottom {
width: 200px;
height: 200px;
position: absolute;
top: 5px;
left: 5px;
}
.top {
z-index: 1;
border: 1px solid #000;
}
这样就能实现一个遮罩效果,你会发现点击按钮无效。

回答4:

定位方式
margin负值