Container
A responsive container for fixing element's width based on current breakpoints.
Class | Breakpoint | Properties |
---|---|---|
container | none | widtd: 100%; |
sm (640px) | max-width: 40rem | |
md (768px) | max-width: 48rem | |
lg (1024px) | max-width: 64rem | |
xl (1280px) | max-width: 80rem | |
2xl (1536px) | max-width: 96rem |
Basic usage
The container class sets the maximum width of an element based on the current responsive breakpoint. Each breakpoint defines a maximum width that scales with the viewport.
This approach allows layouts to adapt to predefined screen sizes rather than relying on a fully fluid viewport. It uses media queries with width >= …
to set the container’s maximum width.
<div class="container">
<!-- content -->
</div>
To add horizontal padding, use the px-*
utilities:
<div class="container px-4">
<!-- content -->
</div>
Responsive variants
The container
class supports responsive variants out of the box. These variants make it possible to apply container behavior only at specific breakpoints and above.
For example:
<div class="md:container">
<!-- Content -->
</div>