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