min-h-screen in Tailwind CSS
min-h-screen in Tailwind CSS means:
min-height: 100vh;
So the element’s minimum height becomes the full height of the browser viewport.
Example:
<div class="min-h-screen bg-gray-100">
Content
</div>
This makes the <div> at least as tall as the screen.
Common use cases:
Full-page layouts
Centering content vertically
Sticky footer layouts
Hero sections
Example with centered content:
<div class="min-h-screen flex items-center justify-center">
<h1>Hello</h1>
</div>
flexenables flexboxitems-centercenters verticallyjustify-centercenters horizontallymin-h-screengives the container full screen height
Difference from h-screen:
| Class | Meaning |
|---|---|
h-screen | exact height = screen height |
min-h-screen | minimum height = screen height, can grow taller |
So if content becomes larger than the screen:
h-screenmay overflowmin-h-screenexpands naturally and is usually safer for pages
Comments
Post a Comment