1

I have a scenario with a code like this

 <li>
  <span class="text">some text goes here</span>
  <div class="icon-wrapper">
    <span class="icon icon1"></span>
    <span class="icon icon2"></span>
  </div>
 </li>

Now all I need is

  1. If I hover on icon1 class, both the .text(class) and .icon1(class) should change its background color respectively.
  2. Similarly if I hover on icon2, .text,.icon1 and .icon2 should change its background color.

I am familiar with combinator selectors in CSS but not able to implement in this case. Here is the screenshot:

enter image description here

enter image description here

Heretic Monkey
  • 10,498
  • 6
  • 45
  • 102
Blah Blah
  • 120
  • 1
  • 5
  • 5
    Is not possible, as one can't select parent element – Ason Apr 24 '17 at 17:49
  • If you can give us a _visual layout_, like a drawing, of what you are looking for, there might be a possibility – Ason Apr 24 '17 at 17:51
  • css can only change descendant or adjacent elements. You might be able to figure a workaround as LGSon mentions. Check out this question to see what's possible: http://stackoverflow.com/questions/6867257/is-there-any-way-to-hover-over-one-element-and-affect-a-different-element – Z. Bagley Apr 24 '17 at 17:52
  • Possible duplicate of [Is there a CSS parent selector?](http://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector) – hungerstar Apr 24 '17 at 17:57
  • Is it not possible to do it if you hover over the `
  • ` or not?
  • – Sank6 Apr 24 '17 at 18:01
  • I have attached the image now please have a look at it. – Blah Blah Apr 24 '17 at 18:03
  • It's a bit confusing why, if you hover over icon2, both icon1 and icon2 change their background colors. In your screenshot, that means if they hovered over the inbox icon, the share icon would also change color... – Heretic Monkey Apr 24 '17 at 18:20