tailwindcss/docs/source/docs/z-index.blade.md

167 lines
6.8 KiB
Markdown
Raw Normal View History

2017-10-28 07:37:05 -04:00
---
extends: _layouts.documentation
2017-10-28 07:37:05 -04:00
title: "Z-Index"
description: "Utilities for controlling the stack order of an element."
2017-11-07 16:27:03 -05:00
features:
responsive: true
customizable: true
hover: false
focus: false
2017-10-28 07:37:05 -04:00
---
@include('_partials.class-table', [
'rows' => [
[
'.z-0',
'z-index: 0;',
"Set the z-index of the element to 0.",
],
[
'.z-10',
'z-index: 10;',
"Set the z-index of the element to 10.",
],
[
'.z-20',
'z-index: 20;',
"Set the z-index of the element to 20.",
],
[
'.z-30',
'z-index: 30;',
"Set the z-index of the element to 30.",
],
[
'.z-40',
'z-index: 40;',
"Set the z-index of the element to 40.",
],
[
'.z-50',
'z-index: 50;',
"Set the z-index of the element to 50.",
],
[
'.z-auto',
'z-index: auto;',
"Don't create a new stacking context.",
],
]
])
2017-10-28 07:37:05 -04:00
2017-10-30 09:26:20 -04:00
## Usage
2017-10-28 07:37:05 -04:00
Control the stack order (or three-dimensional positioning) of an element in Tailwind, regardless of order it has been displayed, using the `.z-{index}` utilities.
@component('_partials.code-sample')
<div class="relative h-32 text-center">
2017-11-09 13:55:51 -05:00
<div class="z-40 absolute w-24 h-24 ml-0 mt-0 bg-grey-light flex justify-center items-center">z-40</div>
<div class="z-30 absolute w-24 h-24 ml-2 mt-2 bg-grey flex justify-center items-center">z-30</div>
<div class="z-20 absolute w-24 h-24 ml-4 mt-4 bg-grey-dark flex justify-center items-center">z-20</div>
<div class="z-10 absolute w-24 h-24 ml-6 mt-6 bg-grey-darker flex justify-center items-center">z-10</div>
<div class="z-0 absolute w-24 h-24 ml-8 mt-8 bg-grey-darkest flex justify-center items-center">z-0</div>
2017-10-28 07:37:05 -04:00
</div>
@slot('code')
2017-10-31 21:04:54 -04:00
<div class="z-40 ml-0 mt-0 bg-grey-light">z-40</div>
<div class="z-30 ml-2 mt-2 bg-grey">z-30</div>
<div class="z-20 ml-4 mt-4 bg-grey-dark">z-20</div>
<div class="z-10 ml-6 mt-6 bg-grey-darker">z-10</div>
<div class="z-0 ml-8 mt-8 bg-grey-darkest">z-0</div>
2017-10-28 07:37:05 -04:00
@endslot
@endcomponent
## Responsive
2017-11-01 16:05:57 -02:00
To control the z-index of an element at a specific breakpoint, add a `{screen}:` prefix to any existing z-index utility. For example, use `md:z-50` to apply the `z-50` utility at only medium screen sizes and above.
2017-10-28 07:37:05 -04:00
2017-11-02 16:08:17 -04:00
For more information about Tailwind's responsive design features, check out the [Responsive Design](/docs/responsive-design) documentation.
2017-10-28 07:37:05 -04:00
@component('_partials.responsive-code-sample')
@slot('none')
<div class="relative w-full h-32 text-center">
2017-11-09 13:55:51 -05:00
<div class="z-0 absolute w-full h-12 mt-12 bg-yellow-light flex justify-center items-center">yellow</div>
<div class="z-40 absolute w-24 h-24 ml-4 mt-0 bg-grey-light flex justify-center items-center">z-40</div>
<div class="z-30 absolute w-24 h-24 ml-6 mt-2 bg-grey flex justify-center items-center">z-30</div>
<div class="z-20 absolute w-24 h-24 ml-8 mt-4 bg-grey-dark flex justify-center items-center">z-20</div>
<div class="z-10 absolute w-24 h-24 ml-10 mt-6 bg-grey-darker flex justify-center items-center">z-10</div>
<div class="z-0 absolute w-24 h-24 ml-12 mt-8 bg-grey-darkest flex justify-center items-center">z-0</div>
2017-10-28 07:37:05 -04:00
</div>
@endslot
@slot('sm')
<div class="relative h-32 text-center">
2017-11-09 13:55:51 -05:00
<div class="z-10 absolute w-full h-12 mt-12 bg-yellow-light flex justify-center items-center">yellow</div>
<div class="z-40 absolute w-24 h-24 ml-4 mt-0 bg-grey-light flex justify-center items-center">z-40</div>
<div class="z-30 absolute w-24 h-24 ml-6 mt-2 bg-grey flex justify-center items-center">z-30</div>
<div class="z-20 absolute w-24 h-24 ml-8 mt-4 bg-grey-dark flex justify-center items-center">z-20</div>
<div class="z-10 absolute w-24 h-24 ml-10 mt-6 bg-grey-darker flex justify-center items-center">z-10</div>
<div class="z-0 absolute w-24 h-24 ml-12 mt-8 bg-grey-darkest flex justify-center items-center">z-0</div>
2017-10-28 07:37:05 -04:00
</div>
@endslot
@slot('md')
<div class="relative h-32 text-center">
2017-11-09 13:55:51 -05:00
<div class="z-20 absolute w-full h-12 mt-12 bg-yellow-light flex justify-center items-center">yellow</div>
<div class="z-40 absolute w-24 h-24 ml-4 mt-0 bg-grey-light flex justify-center items-center">z-40</div>
<div class="z-30 absolute w-24 h-24 ml-6 mt-2 bg-grey flex justify-center items-center">z-30</div>
<div class="z-20 absolute w-24 h-24 ml-8 mt-4 bg-grey-dark flex justify-center items-center">z-20</div>
<div class="z-10 absolute w-24 h-24 ml-10 mt-6 bg-grey-darker flex justify-center items-center">z-10</div>
<div class="z-0 absolute w-24 h-24 ml-12 mt-8 bg-grey-darkest flex justify-center items-center">z-0</div>
2017-10-28 07:37:05 -04:00
</div>
@endslot
@slot('lg')
<div class="relative h-32 text-center">
2017-11-09 13:55:51 -05:00
<div class="z-30 absolute w-full h-12 mt-12 bg-yellow-light flex justify-center items-center">yellow</div>
<div class="z-40 absolute w-24 h-24 ml-4 mt-0 bg-grey-light flex justify-center items-center">z-40</div>
<div class="z-30 absolute w-24 h-24 ml-6 mt-2 bg-grey flex justify-center items-center">z-30</div>
<div class="z-20 absolute w-24 h-24 ml-8 mt-4 bg-grey-dark flex justify-center items-center">z-20</div>
<div class="z-10 absolute w-24 h-24 ml-10 mt-6 bg-grey-darker flex justify-center items-center">z-10</div>
<div class="z-0 absolute w-24 h-24 ml-12 mt-8 bg-grey-darkest flex justify-center items-center">z-0</div>
2017-10-28 07:37:05 -04:00
</div>
@endslot
@slot('xl')
<div class="relative h-32 text-center">
2017-11-09 13:55:51 -05:00
<div class="z-40 absolute w-full h-12 mt-12 bg-yellow-light flex justify-center items-center">yellow</div>
<div class="z-40 absolute w-24 h-24 ml-4 mt-0 bg-grey-light flex justify-center items-center">z-40</div>
<div class="z-30 absolute w-24 h-24 ml-6 mt-2 bg-grey flex justify-center items-center">z-30</div>
<div class="z-20 absolute w-24 h-24 ml-8 mt-4 bg-grey-dark flex justify-center items-center">z-20</div>
<div class="z-10 absolute w-24 h-24 ml-10 mt-6 bg-grey-darker flex justify-center items-center">z-10</div>
<div class="z-0 absolute w-24 h-24 ml-12 mt-8 bg-grey-darkest flex justify-center items-center">z-0</div>
2017-10-28 07:37:05 -04:00
</div>
@endslot
@slot('code')
<div class="none:z-0 sm:z-10 md:z-20 lg:z-30 xl:z-40 bg-yellow-light">yellow</div>
2017-10-31 21:04:54 -04:00
<div class="z-40 ml-4 mt-0 bg-grey-light">z-40</div>
<div class="z-30 ml-6 mt-2 bg-grey">z-30</div>
<div class="z-20 ml-8 mt-4 bg-grey-dark">z-20</div>
<div class="z-10 ml-10 mt-6 bg-grey-darker">z-10</div>
<div class="z-0 ml-12 mt-8 bg-grey-darkest">z-0</div>
2017-10-28 07:37:05 -04:00
@endslot
@endcomponent
## Customizing
By default Tailwind provides six numeric `z-index` utilities and an `auto` utility. You change, add, or remove these by editing the `zIndex` section of your Tailwind config.
2017-10-28 07:37:05 -04:00
@component('_partials.customized-config', ['key' => 'zIndex'])
'0': 0,
- '10': 10,
- '20': 20,
- '30': 30,
- '40': 40,
- '50': 50,
+ '25': 25,
+ '50': 50,
+ '75': 75,
+ '100': 100,
'auto': 'auto',
2017-11-09 13:55:51 -05:00
@endcomponent
2017-12-02 19:29:23 +01:00
2017-12-03 02:35:38 +01:00
@include('_partials.variants-and-disabling', [
'utility' => [
'name' => 'z-index',
'property' => 'zIndex',
],
'variants' => [
'responsive',
],
])