Custom classes added responsive variants didn't work
I know where the problem is: I use windicss as my alternative to Tailwind, but there is some strange differences between their grammar. For example, the correct grammar of the windicss is
@variants lg {
.lg\:img-box-lg {
height: 9.2vw;
}
}
Hidden on Custom Breakpoint Breaks All Breakpoints' Display Value in Tailwind
To hide and element until a specific width use hidden
to hide the element and another display class with responsive modifier (e.g. md:flex
) to show it again.
So basically this should fit your needs:
<div class="bg-gray-500 hidden md:flex">
<h1>foo</h1>
</div>
See https://play.tailwindcss.com/Nb0QOhn9E7 for a working snippet.
Combining a responsive hidden (e.g. xs:hidden
) and with another responsive display class (e.g. md:flex
) doesnt work as the specifity of both css selectors is the same (both use a single class selector inside a mediaquery) so the md:flex
does not overwrite it.
Therefore use non-responsive hidden
(single class selector) which is less specific then md:flex
(single class selector inside a mediaquery) so it gets overwritten for md
upwards.
Theres also a issue in tailwind-css github regarding this behaviour:
https://github.com/tailwindlabs/tailwindcss/issues/841
Related Topics
How Md-Icons Are Rendered on Browser
How to Select The Last-Child of The Last-Child
Add All CSS Files in a Folder to Nuxt.Config
Angular Materials Won't Apply Styles to Components
Only First Media Query Working
How to Keep Mat-Datepicker Calender Open, Even After Selecting a Date from Calendar
Center Vertically The Content of a Div ( Not by Line-Height )
Hide Parts of Site on Mobile Devces
Strategies for Handling Multiple Screen Resolutions and Aspect Ratios in Web Development
†Appearing Instead of Quotation Marks
Vertical Vim Cursor in Command Mode
@Font-Face Does Not Work Properly for Italic/Bold Fonts
CSS: How to Shrink First Div in Container Instead of Going Outside of Container
Skew The Shadow, Not The Content