tailwindcss/docs/source/styles/flexbox/justify-content.blade.md

173 lines
7.3 KiB
Markdown

---
extends: _layouts.markdown
title: "Justify Content - Flexbox"
category: "Flexbox"
---
# Justify Content
<div class="text-xl text-slate-light mb-4">
Utilities for controlling flex items are positioned along a container's main axis.
</div>
@include('_partials.feature-badges', [
'responsive' => true,
'customizable' => false,
'hover' => false,
'focus' => false
])
<div class="border-t border-grey-lighter">
<table class="w-full text-left" style="border-collapse: collapse;">
<colgroup>
<col class="w-1/5">
<col class="w-1/3">
<col>
</colgroup>
<thead>
<tr>
<th class="text-sm font-semibold text-grey-darker p-2 bg-grey-lightest">Class</th>
<th class="text-sm font-semibold text-grey-darker p-2 bg-grey-lightest">Properties</th>
<th class="text-sm font-semibold text-grey-darker p-2 bg-grey-lightest">Description</th>
</tr>
</thead>
<tbody class="align-baseline">
<tr>
<td class="p-2 border-t border-smoke-light font-mono text-xs text-purple-dark">.justify-start</td>
<td class="p-2 border-t border-smoke-light font-mono text-xs text-blue-dark">justify-content: flex-start;</td>
<td class="p-2 border-t border-smoke-light text-sm text-grey-darker">Justify items against the start of the container.</td>
</tr>
<tr>
<td class="p-2 border-t border-smoke-light font-mono text-xs text-purple-dark">.justify-center</td>
<td class="p-2 border-t border-smoke-light font-mono text-xs text-blue-dark">justify-content: center;</td>
<td class="p-2 border-t border-smoke-light text-sm text-grey-darker">Justify items in the center of the container.</td>
</tr>
<tr>
<td class="p-2 border-t border-smoke-light font-mono text-xs text-purple-dark">.justify-end</td>
<td class="p-2 border-t border-smoke-light font-mono text-xs text-blue-dark">justify-content: flex-end;</td>
<td class="p-2 border-t border-smoke-light text-sm text-grey-darker">Justify items against the end of the container.</td>
</tr>
<tr>
<td class="p-2 border-t border-smoke-light font-mono text-xs text-purple-dark">.justify-between</td>
<td class="p-2 border-t border-smoke-light font-mono text-xs text-blue-dark">justify-content: space-between;</td>
<td class="p-2 border-t border-smoke-light text-sm text-grey-darker">Justify items by adding an equal amount of space between each one.</td>
</tr>
<tr>
<td class="p-2 border-t border-smoke-light font-mono text-xs text-purple-dark">.justify-around</td>
<td class="p-2 border-t border-smoke-light font-mono text-xs text-blue-dark">justify-content: space-around;</td>
<td class="p-2 border-t border-smoke-light text-sm text-grey-darker">Justify items by adding an equal amount of space around each one.</td>
</tr>
</tbody>
</table>
</div>
### Start <span class="ml-2 font-semibold text-slate-light text-sm uppercase tracking-wide">Default</span>
Use `.justify-start` to justify items against the start of the flex container's main axis:
@component('_partials.code-sample')
<div class="flex justify-start bg-smoke-light">
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">1</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">2</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">3</div>
</div>
@endcomponent
### Center
Use `.justify-center` to justify items along the center of the flex container's main axis:
@component('_partials.code-sample')
<div class="flex justify-center bg-smoke-light">
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">1</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">2</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">3</div>
</div>
@endcomponent
### End
Use `.justify-end` to justify items against the end of the flex container's main axis:
@component('_partials.code-sample')
<div class="flex justify-end bg-smoke-light">
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">1</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">2</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">3</div>
</div>
@endcomponent
### Space between
Use `.justify-between` to justify items along the flex container's main axis such that there is an equal amount of space between each item:
@component('_partials.code-sample')
<div class="flex justify-between bg-smoke-light">
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">1</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">2</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">3</div>
</div>
@endcomponent
### Space around
Use `.justify-around` to justify items along the flex container's main axis such that there is an equal amount of space around each item:
@component('_partials.code-sample')
<div class="flex justify-around bg-smoke-light">
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">1</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">2</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">3</div>
</div>
@endcomponent
## Responsive
To justify flex items at a specific breakpoint, add a `{breakpoint}:` prefix to any existing utility class. For example, use `md:justify-between` to apply the `justify-between` utility at only medium screen sizes and above.
For more information about Tailwind's responsive design features, check out the [Responsive Design](#) documentation.
@component('_partials.responsive-code-sample')
@slot('none')
<div class="flex justify-start bg-smoke-light">
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">1</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">2</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">3</div>
</div>
@endslot
@slot('sm')
<div class="flex justify-center bg-smoke-light">
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">1</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">2</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">3</div>
</div>
@endslot
@slot('md')
<div class="flex justify-end bg-smoke-light">
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">1</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">2</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">3</div>
</div>
@endslot
@slot('lg')
<div class="flex justify-between bg-smoke-light">
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">1</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">2</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">3</div>
</div>
@endslot
@slot('xl')
<div class="flex justify-around bg-smoke-light">
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">1</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">2</div>
<div class="text-slate text-center bg-smoke px-4 py-2 m-2">3</div>
</div>
@endslot
@slot('code')
<div class="none:justify-start sm:justify-center md:justify-end lg:justify-between xl:justify-around ...">
<!-- ... -->
</div>
@endslot
@endcomponent