css中z-index无效的解决办法

z-index一定要与position:relative/absolute连用。否则无效

灰色是蒙版,他应该覆盖在立即领取按钮上面,但是现在明显相反。

因为position的默认值是static。浏览器会按照源码的顺序,决定每个元素的位置,这称为”正常的页面流”。static定位所导致的元素位置,是浏览器自主决定的,会忽略top、right、bottom、left和z-index属性

所以在使用z-index的时候,需要改变position的默认值。

猜你喜欢

转载自blog.csdn.net/qq_56715703/article/details/131093116