I have 4 elements on top of each other, with the following opacity settings (from bottom to top):
- id - 0
- id - 0
- div - 1
- text - 1
I need that by hover element 2, the changes of the opacity settings will be:
- id - 1
- id - doesn't matter
- div - 1
- text - 0
Because element 2 is my trigger, I need both elements 3+4 to be pointer-events:none
, so the hover will affect element 2 (that is under them).
I believe the reason both of these elements don't change is that pointer-events:none
. am i correct?
body {
position: relative;
width: 100vw;
height: 100vh;
background-color: rgb(234, 255, 248);
justify-content: center;
}
#background {
position: absolute;
background-color:rgb(255, 125, 125);
width: 300px;
height: 90px;
opacity: 0;
}
#animation {
position: absolute;
background-color: rgb(25, 138, 0);
width: 200px;
height: 50px;
opacity: 0;
}
.squares {
position: absolute;
background-color: purple;
height: 30px;
width: 50px;
opacity: 1;
}
.A {
color: aliceblue;
}
.text {
position: absolute;
color: red;
pointer-events: none;
}
.squares:hover ~ #background {
opacity: 1;
}
.squares:hover ~ #animation {
opacity: 1;
}
.squares:hover ~ .text {
opacity: 0;
}
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="c">
<div class="squares">
<div class="A">13</div>
</div>
<div id="background">11</div>
<div id="animation">11</div>
<div class="text">
PARTICIPATE TO VIEW IMGS
</div>
</div>
</body>
</html>