I have this code:
body {
background-color: darkgray;
font-size: 2em;
}
div {
margin: 2em;
}
#outer {
background-color: purple;
border: 2px solid transparent;
}
#outer:hover {
cursor: pointer;
opacity: 40%;
border: 2px solid yellow;
}
#first:hover {
color: red;
font-weight: bold;
cursor: pointer;
}
#first:hover #outer {
background-color: green;
opacity: 100%;
}
<div id="outer">
Outer
<div id="first">
First
</div>
</div>
It shows this:
When I hover over #outer
it shows this:
When I hover over #first
it shows this:
I'd like it to make the #outer
background green and its opacity 100%, when the #first
is hovered over.
However, it doesn't happen - when #first
is hovered, the #outer
background stays purple and its opacity stays 40%. How do I fix it?
EDIT:
I'm OK with updating all elements (for instance if there are more outer
elements than one). And I don't want to use Javascript!