I have 8 nested divs inside a container div. I'd like it so when you hover over a div the opacity changes on all the other divs within the same container. I'm sure this can be done purely using css (if not i'm happy to do using jQuery). I've tried using the sibling of the container ~ and it's kind of working but not 100% correct.
Here's my HTML:
<div class="container">
<div class="something"><div class="element">Panel 1</div></div>
<div class="something"><div class="element">Panel 2</div></div>
<div class="something"><div class="element">Panel 3</div></div>
<div class="something"><div class="element">Panel 4</div></div>
<div class="something"><div class="element">Panel 5</div></div>
<div class="something"><div class="element">Panel 6</div></div>
<div class="something"><div class="element">Panel 7</div></div>
<div class="something"><div class="element">Panel 8</div></div>
</div>
and here's my CSS:
.something:hover ~ div {
opacity: 0.4;
}
Here's a working jsFiddle: https://jsfiddle.net/kxz4fjys/
You can see on the jsFiddle it's kind of working but not exactly right. Any ideas?