Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tailwind CSS hidden and visible

Backend dev here learning front. I am trying to hide an element on small and medium screens and visible on the rest of the screens.

But the thing is when I do sm:hidden it hides the element for small screens and above. And when I try to do sm:hidden md:visible the element is not visible on medium screens and above. How should I go about this?

like image 766
carl Avatar asked Jun 16 '26 21:06

carl


1 Answers

As we can read in official docs :

By default, Tailwind uses a mobile-first breakpoint system

Then In Your case on small breakpoint hidden and visible on Large lg breakpoints and above :

<div class="hidden lg:block">
  <!-- ... -->
</div>

Example:

<!doctype html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="https://cdn.tailwindcss.com"></script>
</head>

<body>
  <div class="hidden lg:block">
    <h1 class="text-3xl font-bold underline">
      Hello world!
    </h1>
  </div>

</body>

</html>

enter image description here

like image 117
MarioG8 Avatar answered Jun 20 '26 12:06

MarioG8



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!