-1

I began to use tailwind a few days ago, i succeeded to install, make it builting fine, but when my page was ended, nothing was working after running content (the purge of unnecessary css). So i correct the file output, adding forgotten classes by tailwing purge process.

But my responsive windows were working before this production step : i mean for mobile under 640px, i had a background image (640 x 1024) and other properties, and for larger screens upper to 640 i had another background image (1024 x 640) with other properties for larger screens.

I do not find any classes sm or biggers in the output.css file and when i pass through 640px in browsers inspection nothing happens, the page is blocked on sm properties.

Below the main div for mobile screens :

<div class="conteneur_sm flex flex-col h-screen items-center sm:hidden bg-image_sm bg-no-repeat"> <!-- mobiles only -->
    <div class="font-mashan text-shadow_sm text-center text-6xl  mt-6 mb-6">打有 字汇</div>
        <div class="custom-height-up flex">

And here the main div for bigger screens :

<div class="conteneur hidden sm:flex flex-col h-screen items-center bg-image bg-repeat">  <!--  larger_screens_only -->
        <div class="font-mashan text-shadow_wide text-center text-7xl  mt-8 mb-8">打有 字汇</div>
                <div class="custom-height-down flex">

The first main div is visible only for mobile screens (by using : flex and sm:hidden ) and uses the bg-image_sm. The second main div is visible from 640px (by using hidden and sm:flex ). For a reason that i do not know, these properties weren't save in my output.css

and i wonder how write the classes sm and bigger in css syntax in my output.css production file.

edited on 13th august (asked a bot):
In Tailwindcss syntax, would you explain me what means "" in :

@media (min-width:640px) {.sm/:flex {display: flex;} .sm/:hidden {display: none;} }    

Is this character available in CSS syntax ? It is hard for me to transcript the responsive classes sm, md, lg, xl and 2xl of Tailwind in a pure CSS syntax :-( ChatGPT
Hello! In the context of Tailwind CSS, the "" character is used as an escape character that allows you to use special characters in class names that would otherwise be invalid in regular CSS syntax. This is especially useful when dealing with responsive utility classes like those based on breakpoints (e.g., sm, md, lg, xl, 2xl) in Tailwind.

Here's how it works:

In Tailwind CSS, you often use breakpoint-based classes like .sm:flex or .md:hidden to apply styles at specific screen sizes. However, if you were to write this in pure CSS, it would be invalid because the colon (:) and period (.) are not allowed characters in class names. CSS class names can only contain letters, numbers, hyphens, and underscores.

Tailwind solves this issue by allowing you to use the backslash () as an escape character. So, in the context of your example:

The : in .sm:flex and .sm:hidden is used to escape the colon character, allowing Tailwind to generate the correct class names for you. The resulting CSS classes would be .sm:flex and .sm:hidden.

In pure CSS, you would not need to use the escape character, as the colon is a valid character for class names. However, creating responsive styles similar to Tailwind's utility classes would require writing out media queries manually for each breakpoint.

For example, in pure CSS, you might write:

@media (min-width:640px) {.sm-flex {display: flex;} .sm-hidden {display: none;} }     

/* And so on for other breakpoints */ It's worth mentioning that while using Tailwind CSS provides a lot of convenience for rapid development, replicating the exact same utility classes in pure CSS can be more verbose and time-consuming. This is one of the trade-offs to consider when choosing between a utility-first framework like Tailwind and traditional CSS approaches.

faure
  • 93
  • 8
  • 1
    I don't use *Tailwind*, but this took me a at least a minute to find: [CheatSheet](https://nerdcave.com/tailwind-cheat-sheet) – Rene van der Lende Aug 12 '23 at 13:15
  • Thank you so much for this fantastic table ! which deserve to be updated to 3.3.n :-) i try immediately ".sm:flex display: flex; " found in display frame – faure Aug 13 '23 at 03:16
  • This table is fine, but find the transcription of responsive classes is not easy at all. – faure Aug 13 '23 at 03:43
  • Before I already tried to write @media (min-width: 640px) { .sm:flex { display: flex; } .sm:hidden { display: none; } } in my output.css file which was not working :-( maybe I have a syntax problem. The matter is to hide (larger) div below 640 px and display flex the (mobile) div; and hide the (mobile) div, displaying the (larger) div, when devices are upper to 640 px. In tailwind it needs only "flex & sm:hidden" in first div and "hidden & sm:flex" in 2nd div. Tailwind is by default set for sm size. But CSS in output file can't use sm, md, lg... :-( – faure Aug 13 '23 at 03:55
  • @Rene-van-der-Lende I uploaded code to a pen https://codepen.io/seeeerge/pen/WNYVeJq we can see that sm-hidden is not working for an unknown reason as the two divs are displayed even when the screen wide is below 640 ! more : the first div shouln't be displayed on computer or tab with screens wider than 640px. Do not yet find what is the problem ! very disappointed by Tailwindcss and its "pseudo purge"... – faure Aug 13 '23 at 06:04
  • I’m voting to close this question because chatgpt content is not allowed on SO – Rob Aug 13 '23 at 11:43
  • @Rob I'm surely not the only one to have issues with output.css of Tailwind, and I am still looking for a solution. Why Tailwind does it set for mobiles by default ? and how this can be written in pure CSS ? when I will have the answer and the solution, this post can help ! you do not help at all – faure Aug 14 '23 at 03:38

0 Answers0