混合模式 mix-blend-mode
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="main">
<div class="box2"></div>
<div class="box1"></div>
<div class="box3">这是测试</div>
</div>
</body>
<style>
.main {
position: relative;
}
.box1 {
width: 100%;
height: 200px;
background: #FFF;
}
.box2 {
width: 100%;
height: 200px;
background: #000;
}
.box3 {
position: absolute;
mix-blend-mode: difference;
color: #FFF;
top: 160px;
left: 50%;
animation: move 1s infinite linear alternate
}
@keyframes move {
0% {
transform: translateY(0);
}
100% {
transform: translateY(60px);
}
}
</style>
</html>