Place items
The place items class sets the place-items
property. It is a shorthand for setting the cross axis and the main axis. It controls how items are aligned inside their grid areas along both axes in a grid container.
justify-items
is ignored, so place-items
has no effect.CSS Shortcut class | Applied style |
---|---|
|
|
|
|
|
|
|
|
Examples
Centre
place-items-center
These items are centred both vertically and horizontally within their grid areas.
1
2
3
4
5
6
<div class="d-grid grid-cols-3 place-items-center">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
</div>
Stretch
place-items-stretch
These items stretch to fill their grid areas both horizontally and vertically, if no fixed size is set.
1
2
3
4
5
6
<div class="d-grid grid-cols-3 place-items-stretch">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
</div>
Start
place-items-start
These items align to the start edge of both axes within their grid areas.
1
2
3
4
5
6
<div class="d-grid grid-cols-3 place-items-start">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
</div>
End
place-items-end
These items align to the end edge of both axes within their grid areas.
1
2
3
4
5
6
<div class="d-grid grid-cols-3 place-items-end">
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
</div>
xs
:> 480px
sm
:> 640px
md
:> 768px
lg
:> 1024px
xl
:> 1280px
<div class="xs:place-items-center ...">
...
</div>