2 ms·
One example is to "inherit" class styles. E.g. let's say I have some html like <p class="warning">be very careful<p> and there is some 3rd party CSS that alrea
by valenterry 5y ago
One example is to "inherit" class styles.
E.g. let's say I have some html like <p class="warning">be very careful<p> and there is some 3rd party CSS that already has nice styling for a warning paragraph. But it uses .warn as a class, not .warning.
I don't want to change my HTML and I also don't want to copy the style.
I want to tell CSS that my own .warning should inherit the style of .warn (and maybe adjust it slightly if necessary)
That is (to my knowledge) currently not possible.
- Semaphor 5y agoOnly semi-relevant, but this is possible with SASS’s @extend: https://sass-lang.com/documentation/at-rules/extend https://sass-lang.com/documentation/at-rules/extend
- moritzwarhier 5y agoBecause the output is still CSS, this would lead to a lengthened (redundant) selector though. Also, AFAIK it would be impossible with a class that is not part of your SCSS tree. If you are able to import the library CSS in to your own SCSS, OK, no problem. But that would introduce unneeded complexity. If using a bundler and one output file, copying the library CSS rules and applying them to your own could maybe even lead to the same output as @extend - a combined selector .warn, warning (you already kind of addressed all of that already in your "semi-relevant" disclaimer)
- Semaphor 5y ago> (you already kind of addressed all of that already in your "semi-relevant" disclaimer) You make some good points, and I wish I could still edit it to "kind of possible" ;)