当前位置:首页 > 编程技术 > 正文

css如何设置遮罩

css如何设置遮罩

在CSS中,设置遮罩通常是通过使用`position`属性和`z-index`属性来实现的。以下是一些常用的方法来创建遮罩效果: 1. 使用`position: fix...

在CSS中,设置遮罩通常是通过使用`position`属性和`z-index`属性来实现的。以下是一些常用的方法来创建遮罩效果:

1. 使用`position: fixed;`创建全屏遮罩

```css

.mask {

position: fixed;

top: 0;

left: 0;

width: 100%;

height: 100%;

background-color: rgba(0, 0, 0, 0.5); / 半透明白色遮罩 /

z-index: 1000; / 确保遮罩在顶层 /

最新文章