Answer the question
In order to leave comments, you need to log in
How can a block with position:fixed change color when passing a certain border?
It is necessary that when scrolling the page on a blue background it is white, and on a red one it is blue
Here is an example code
<!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">
<link rel="stylesheet" href="css.css">
<title>Document</title>
</head>
<body>
<div class="fixed"></div>
<div class="block red"></div>
<div class="block blue"></div>
<div class="block red"></div>
<div class="block blue"></div>
</body>
</html>
.block {
width: 100%;
height: 200px;
}
.red {
background: red;
}
.blue {
background: blue;
}
.fixed {
position: fixed;
background: blue;
top: 100px;
left: 100px;
z-index: 10;
width: 80px;
height: 80px;
}
Answer the question
In order to leave comments, you need to log in
make 2 fixed blocks in one place. one blue, the other red, in both mix-blend-mode: exclusion
https://jsfiddle.net/hc0v3qgy/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question