This question already has an answer here:
- Is there a “previous sibling” CSS selector? 13 answers
In CSS there is no way to select a sibling with plus if the sibling is above in the output, a preceding element in the html.
For example
<div class="first">
<div class="second">
.second + .first { style applied to div.first}
Is there anyway to do this in SASS/SCSS?
SASS support all CSS3 selectors. Sibling + is one of them. But it does not bring some extra features. It means you can do
But you can't impact a parent with it ...
Ps : it seems to be a features of CSS4 :)
I ended up using Jquery. gets the job done :) (sorry i dont have the example code anymore as i went another route, but its quite simple, something like 'if child has class then add class to this'. :)
I know the feeling, this is really annoying. I found a quick way of doing it tho.
HTML:
-------->
SCSS:
====> thgaskell, you have proved me wrong :) My code works fine and I lost 6KB of my Minified code! I have updated the code as how the comment below was informed.
try it it's work.
May or may not be suitable for your needs but you can use the general sibling selector in Sass/CSS. This will select all elements on the same node level (not explicitly before but still handy):