<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<div class="background1">Div1</div>
<div class="background2">Div2</div>
<div class="background3">Div3</div>
<div class="background4">Div4</div>
<div class="fixed-background">This should change color based on background</div>
</body>
</html>
div {
height: 100vh;
}
.background1 {
background: gray;
}
.background2 {
background: black;
}
.background3 {
background: blue;
}
.background4 {
background: tomato;
}
.fixed-background {
position: fixed;
top: 10px;
left: 10px;
width: 100px;
height: 100px;
mix-blend-mode: difference;
}
大家好,我尝试fixed-background
根据其他 div 的背景更改带有类的 div 的背景和颜色。我遇到了mix-blend-mode
CSS 属性,但它似乎不起作用。
到目前为止,我还不是 CSS 专家,有人可以帮我解决这个问题吗?如果我让它与 JS 函数一起工作,我不会不高兴。