📅  最后修改于: 2023-12-03 15:14:18.554000             🧑  作者: Mango
CSS mask-image 属性用于定义一个遮罩层,可以实现对元素的部分区域进行遮罩,从而调整元素的可见性和透明度。通常情况下,遮罩效果可以通过图片、线性渐变、径向渐变、重复图案等方式来实现。
mask-image: none | <url> | <image> | <linear-gradient> | <radial-gradient> | <repeating-linear-gradient> | <repeating-radial-gradient> | inherit;
.mask {
mask-image: url('mask.png');
}
.mask {
mask-image: url('data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4
//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==');
}
.mask {
mask-image: linear-gradient(to bottom, transparent 20%, black 80%);
}
.mask {
mask-image: radial-gradient(circle at center, transparent 20%, black 80%);
}
.mask {
mask-image: repeating-linear-gradient(45deg, yellow, green 10%, yellow 20%);
}