CSS 混合模式:mix-blend-mode: difference
mix-blend-mode
值可以是以下几个:
mix-blend-mode: normal;
mix-blend-mode: multiply;
mix-blend-mode: screen;
mix-blend-mode: overlay;
mix-blend-mode: darken;
mix-blend-mode: lighten;
mix-blend-mode: color-dodge
mix-blend-mode: color-burn;
mix-blend-mode: hard-light;
mix-blend-mode: soft-light;
mix-blend-mode: difference;
mix-blend-mode: exclusion;
mix-blend-mode: hue;
mix-blend-mode: saturation;
mix-blend-mode: color;
mix-blend-mode: luminosity;
mix-blend-mode: difference,意为差值模式
该混合模式会查看每个通道中的颜色信息,比较底色和绘图色,用较亮的像素点的像素值减去较暗的像素点的像素值。
与白色混合将使底色反相;与黑色混合则不产生变化。
通俗一点就是上方图层的亮区将下方图层的颜色进行反相,暗区则将颜色正常显示出来,效果与原图像是完全相反的颜色。
<div class="main"></div>
.main{
width: 100%;
height: 100%;
background: linear-gradient(45deg, #000 0, #000 50%, #fff 50%);
position: relative;
&::before{
content:'LOADING';
position: absolute;
font-size: 50px;
width: 100%;
height: 100%;
top: 40%;
left: 20%;
color: #fff;
mix-blend-mode: difference;
animation: move 3s infinite linear alternate;
}
}
@keyframes move {
0% {
transform: translateX(20%);
}
100% {
transform: translateX(-20%);
}
}