0

Usually, when I want to affect a children element by hovering a parent, I'm just doing something like this:

#parent:hover > .children {
    /* ... */
}

But what if I want to affect the parent by hovering a child? I know I can achieve that by using JS, but I would like to know if there's a technique to do so via CSS/SCSS only.

Eliya Cohen
  • 7,443
  • 6
  • 41
  • 82
  • There are really hacky ways you can fake a parent selector, but I would say it is not worth your time or effort - just use JS for something like this – mhodges Jan 24 '17 at 20:12
  • @mhodges, i dont know of any, care to share? – jojomojo Jan 24 '17 at 20:13
  • @jojomojo From what I've seen, in certain cases, you can do some hacky DOM restructuring and use pseudo-selectors. I can't seem to find a specific example, though. – mhodges Jan 24 '17 at 20:19
  • Not possible in pure CSS. Check this answer: http://stackoverflow.com/questions/8114657/how-to-style-the-parent-element-when-hovering-a-child-element – Alessandro Incarnati Jan 24 '17 at 20:19

0 Answers0