How can I make one Tailwind Class more specific without exclamation mark?

Viewed 155

I can force override class specificity like this in Tailwind CSS 3.0.

<div class="p-1 !p-2">test</div>

However, I occasionally want to override the !p-2, but extra exclamation mark !!p-3 is not enabled; how can I do this?

1 Answers

"!" is the !important in CSS.
It is to override the class one position lower line in the .css
If it is a responsive website, you can use breakpoints

<div class="p-1 sm:p-2 md:p-3">test</div>

Otherwise, some programming language must be used.

<?php $className = 1 < 2 ? 'true-class' : 'false-class'; ?>
<div class="<?php echo $className; ?>" />

Vue.js

etc... search: your programing language css class bidding

Related