/** 你的浏览器太过老旧,不支持我们在本演示中需要使用的一些css属性,请升级你的浏览器到最新版本。我们需要使用下面两个CSS属性:
filter
background-blend-mode
我们使用 CSS @supports 来检测你的浏览器是否支持这些属性。对于不支持这些CSS属性的浏览器,我们将使用备用方案来呈现这些图片效果。 **/
.warhol-effect {
background-image: url(photo.jpg);
background-size: cover;
background-position: center;
}
@supports (background-blend-mode: color) {
.warhol-effect {
background-image: linear-gradient(#14EBFF 0, #14EBFF 50%, #FFFF70 50%, #FFFF70 100%), linear-gradient(#FF85DA 0, #FF85DA 50%, #AAA 50%, #AAA 100%), url(photo.jpg);
background-size: 50% 100%, 50% 100%, 50% 50%;
background-position: top left, top right;
background-repeat: no-repeat, no-repeat, repeat;
background-blend-mode: color;
}
}
.warhol-effect {
$url : url(photo.jpg);
background-image: $url;
background-size: cover;
background-position: center;
@supports (background-blend-mode: color) {
background-image:
linear-gradient(
#14EBFF 0,
#14EBFF 50%,
#FFFF70 50%,
#FFFF70 100%
),
linear-gradient(
#FF85DA 0,
#FF85DA 50%,
#AAA 50%,
#AAA 100%
),
$url;
background-size: 50% 100%, 50% 100%, 50% 50%;
background-position: top left, top right;
background-repeat: no-repeat, no-repeat, repeat;
background-blend-mode: color;
}
}
CSS SCSS
CodePen
Copy