Tailwind CSS Place-items
The place-items utility class in Tailwind CSS allows you to control the alignment and spacing of grid or flex container items both horizontally and vertically.
Tailwind Place Items
The place-items
utility class in Tailwind CSS allows you to control the alignment and spacing of grid or flex container items both horizontally and vertically. With Tailwind's place-items class, you can easily position and align individual items within a container.
Applying Place Items
To apply the alignment and spacing to individual items within a grid or flex container, you can use the place-items-{alignment}
utility class, where {alignment}
represents the desired alignment. Here are the available alignment options:
- place-items-start: Aligns items to the start of both the horizontal and vertical axes.
- place-items-end: Aligns items to the end of both the horizontal and vertical axes.
- place-items-center: Aligns items to the center of both the horizontal and vertical axes.
- place-items-stretch: Stretches items to fill the container along both axes.
- place-items-auto: Applies automatic item placement, allowing items to be positioned based on their default placement rules.
<div class="grid place-items-center"> <div>A</div> <div>B</div> <div>C</div> <div>D</div> <div>E</div> <div>F</div></div>
Preview
Responsive Place Items
Tailwind CSS allows you to apply place items classes responsively at different breakpoints. To use responsive place items classes, you can append the breakpoint prefix to the utility class. For example, md:place-items-stretch stretches the items to fill the container along both axes starting from the medium breakpoint and above.
<div class="grid place-items-start md:place-items-stretch"> <!-- Grid items here --></div>
In the above example, the items are aligned to the start of both axes by default (place-items-start), but starting from the medium breakpoint and above, the items are stretched to fill the container (md:place-items-stretch).
Tailwind Place-items Class Table
Class | Properties |
---|---|
place-items-auto | place-items: auto; |
place-items-start | place-items: start; |
place-items-end | place-items: end; |
place-items-center | place-items: center; |
place-items-stretch | place-items: stretch; |
Windframe Tailwind blocks
Windframe is a drag and drop builder for rapidly building tailwind css websites and UIs