我想请教一下,使用 CSS 遮罩和自定义属性实现图像碎片效果时,我的分割线很明显,请问通过什么属性可以隐藏呢,我暂未找到解决办法
代码如下:
$x: 10;
/* number of row */
$y: 10;
/* number of columns */
$s: 0.8;
/* speed factor */
@for $i from 0 through ($x - 1) {
@for $j from 0 through ($y - 1) {
@property --c-#{$i}-#{$j} {
syntax: "<number>";
initial-value: 1;
inherits: false;
}
}
}
@function transition($i, $j) {
@return ($s*random())+s ($s*random())+s;
}
@mixin image() {
$all_t: (
);
$all_m: (
);
@for $i from 0 through ($x - 1) {
@for $j from 0 through ($y - 1) {
$all_t: append($all_t, --c-#{$i}-#{$j} transition($i, $j), comma);
$all_m: append($all_m, linear-gradient(rgba(0, 0, 0, var(--c-#{$i}-#{$j})) 0 0) calc(#{$i}*100%/(#{$x} - 1)) calc(#{$j}*100%/(#{$y} - 1)), comma);
}
}
transition: $all_t;
-webkit-mask: $all_m;
mask: $all_m;
}
img {
@include image();
-webkit-mask-size:calc(100%/#{$x}) calc(100%/#{$y});
-webkit-mask-repeat: no-repeat;
mask-size:calc(100%/#{$x}) calc(100%/#{$y});
mask-repeat: no-repeat;
}
img:hover {
@for $i from 0 through ($x - 1) {
@for $j from 0 through ($y - 1) {
--c-#{$i}-#{$j}: 0.7;
}
}
}