Is there a way to prepend a selector directly to the current selector in scss. Consider the following:
.object-fit {
object-fit: cover;
height: 100%;
width: 100%;
overflow: hidden;
}
is there a way to prepend img
so that the output is img.object-fit
?
The only way I have seen for prepending is to add &
after like so:
.object-fit {
img & {
}
}
but this would turn it into a parent child selector: img .object-fit
The normal way would be just to append the second selector with &img
but as this has no dot before the selector, that ends up with a different class name: .object-fitimg
So basically the question is is there anyway inside the object fit class to prepend a bare element selector?
img&
? – TynesInvalid CSS after "img": expected "{", was "&" "&" may only be used at the beginning of a compound selector.
– Regulate@at-root img#{&}
? – Cordwood