Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@rabbi I have a CSS property set by Javascript where the value depends on user interaction, but only in mobile view. For desktop view, the property from CSS shall be used.
Since properties set via JS have priority over those from CSS, I would have to listen on the window resize event and reset that - or I spare that handler and just use !important for desktop view. -
rabbi16186y@Fast-Nop or use a higher select class, which if you are using scss is very easy.
But you can agree that this is a very specific and special use case, I don't think I would call that a 'nice use case'... -
@rabbi !important is meant as exception if used properly, and therefore, the nice use cases of course are the rare corner cases.
What !important is not for, that's including 20 stylesheets all with contradicting definitions of the same classes and then going for damage control with !important. -
@rabbi well you can add !important to a selector with higher specificity , or add an !important override further down the line - but then the order matters, which sucks.
-
@rabbi had to look it up - but come on. I mean, aminations ok, but abusing them for overriding !important would be a really dirty hack.
-
rabbi16186y@Fast-Nop my reasoning is that ! important is already a dirty hack, but just in case someone already used it, you have the nukes ready...
-
@rabbi well, !important is the goto of CSS, but when used with care, it can be OK. The epidemic and dirty use of that probably came from the Wordpress ecosystem (who would have guessed).
Related Rants
My top 3:
* Inline styling instead of creating a class.
* slapping the new class at the end of a 700 LOC CSS file.
* Using !important
rant
lazy devs
wk126
css