aboutsummaryrefslogtreecommitdiff
path: root/files/uk/web/css/css_grid_layout
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:43:23 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:43:23 -0500
commit218934fa2ed1c702a6d3923d2aa2cc6b43c48684 (patch)
treea9ef8ac1e1b8fe4207b6d64d3841bfb8990b6fd0 /files/uk/web/css/css_grid_layout
parent074785cea106179cb3305637055ab0a009ca74f2 (diff)
downloadtranslated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.tar.gz
translated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.tar.bz2
translated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.zip
initial commit
Diffstat (limited to 'files/uk/web/css/css_grid_layout')
-rw-r--r--files/uk/web/css/css_grid_layout/basic_concepts_of_grid_layout/index.html699
-rw-r--r--files/uk/web/css/css_grid_layout/index.html245
-rw-r--r--files/uk/web/css/css_grid_layout/relationship_of_grid_layout/index.html628
3 files changed, 1572 insertions, 0 deletions
diff --git a/files/uk/web/css/css_grid_layout/basic_concepts_of_grid_layout/index.html b/files/uk/web/css/css_grid_layout/basic_concepts_of_grid_layout/index.html
new file mode 100644
index 0000000000..84c95201bb
--- /dev/null
+++ b/files/uk/web/css/css_grid_layout/basic_concepts_of_grid_layout/index.html
@@ -0,0 +1,699 @@
+---
+title: Основна концепція макета grid
+slug: Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout
+tags:
+ - CSS Grid
+ - Посібник
+translation_of: Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout
+---
+<p><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout">CSS Grid Layout</a> вводить двовимірну сітку до CSS. Сітки можуть бути використані для виділення основних областей сторінки або невеликих елементів інтерфейсу користувача. У цій статті надана схема CSS Grid Layout та нова термінологія, що є частиною специфікації CSS Grid Layout Level 1. Функції, наведені в цьому огляді, будуть більш детально пояснені далі в цьому посібнику.</p>
+
+<h2 id="Що_таке_grid">Що таке grid?</h2>
+
+<p>Grid є перехресним набором  горизонтальних і вертикальних ліній, що перетинаються - один набір визначає стовпці,  інший рядки. Елементи можуть бути розміщені на сітці, дотримуючись цих стовпців та рядків. Макет сітки CSS має такі особливості:</p>
+
+<h3 id="Фіксовані_та_гнучкі_розміри_смуг">Фіксовані та гнучкі розміри смуг</h3>
+
+<p>Ви можете створити сітку з фіксованими розмірами смуг – наприклад, використовуючи пікселі. Це встановлює сітку на певні пікселі, що відповідають бажаному макету. Ви також можете створити сітку з використанням гнучких розмірів у відсотках або з новою одиницею <code>fr</code>, яку розроблену саме для цієї мети.</p>
+
+<h3 id="Розміщення_елементів">Розміщення елементів</h3>
+
+<p>Ви можете розміщувати елементи у точному місці сітки, використовуючи номери рядків, імена або орієнтуючись на область сітки. Сітка також містить алгоритм для контролю розміщення елементів, які не мають явного положення на сітці.</p>
+
+<h3 id="Створення_додаткових_смуг_для_вмісту">Створення додаткових смуг для вмісту</h3>
+
+<p>Ви можете визначати сітку явно в макеті сітки, але специфікація також стосується вмісту, доданого за межами оголошеної сітки, додаючи додаткові рядки та стовпчики за потребою. Спрацьовує принцип додавання " стільки стовпчиків, скільки вміститься в контейнер".</p>
+
+<h3 id="Управління_вирівнюванням">Управління вирівнюванням</h3>
+
+<p>Сітка містить функції вирівнювання для того, щоб ми могли контролювати, як вирівнюються розміщені в області сітки елементи  та як вирівнюється вся Grid-сітка.</p>
+
+<h3 id="Управління_вмістом_що_перекривається">Управління вмістом, що перекривається</h3>
+
+<p>У секцію сітки можна додати більш ніж один елемент. Також області можуть частково перекривати одна одну. Цим накладенням можна керувати за допомогою {{cssxref("z-index")}} властивості.</p>
+
+<p>Grid - це потужна специфікація, яка у поєднанні з іншими можливостями CSS такими, як <a href="/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout">flexbox</a>, дозволяє вам створювати макети, які раніше неможливо було створити за допомогою CSS. Все починається шляхом створення сітки у <strong>grid-контейнері</strong>.</p>
+
+<h2 id="Grid-контейнер">Grid-контейнер</h2>
+
+<p>Ми створюємо <em>grid-контейнер </em>оголошуючи <code>display: grid</code> або <code>display: inline-grid</code> на елементі. Як тільки ми це зробимо, всі <em>прямі діти </em>елементу стають <em>grid-елементами</em>.</p>
+
+<p>У цьому прикладі, у мене div-елемент з класом <em>wrapper</em>, що містить в собі п'ять дочірніх елементів.</p>
+
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div&gt;One&lt;/div&gt;
+ &lt;div&gt;Two&lt;/div&gt;
+ &lt;div&gt;Three&lt;/div&gt;
+ &lt;div&gt;Four&lt;/div&gt;
+ &lt;div&gt;Five&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<p>Я роблю з класу <code>.wrapper</code> grid-контейнер.</p>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+}
+</pre>
+
+<div class="hidden">
+<pre class="brush: css line-numbers language-css"><code class="language-css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.wrapper &gt; div {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}</code></pre>
+</div>
+
+<p>{{ EmbedLiveSample('The_Grid_container', '200', '330') }}</p>
+
+<p>Всі прямі нащадки тепер є grid-елементами. В браузері ви не помітите ніякої різниці між виглядом елементів до і після створення grid-контейнеру. З цієї точки зору вам буде корисно працювати в редакторі Firefox Developer Edition, який має <a href="/en-US/docs/Tools/Page_Inspector/How_to/Examine_grid_layouts">Grid Inspector</a>, доступний як частина інструментів розробника. Якщо ви розглянете цей приклад в  Firefox і перевірите grid, ви побачите маленький значок біля значення <code>grid</code>. Клікніть його і сітка накладеться на цей елемент у вікні браузера.</p>
+
+<p><img alt="Using the Grid Highlighter in DevTools to view a grid" src="https://mdn.mozillademos.org/files/14631/1-grid-inspector.png" style="height: 753px; width: 900px;"></p>
+
+<p>Як вийде - працюйте з  CSS Grid Layout, це інструмент надасть вам краще розуміння того що відбувається з вашою grid-сіткою візуально. </p>
+
+<p>Якщо ми хочемо щоб це було більше grid-орієнтовано, треба додавати більше смуг-стовбців.</p>
+
+<h2 id="Grid_Смуги">Grid Смуги</h2>
+
+<p>Ми визначаємо рядки і стовпчики на нашій grid-сітці  властивостями {{cssxref("grid-template-columns")}} та {{cssxref("grid-template-rows")}}. Вони визначають grid смуги. Grid-смуга – це простір будь якими двома лініями на grid-сітці. На зображенні нижче кольорова смуга – перша смуга-рядок на нашій grid-сітці.</p>
+
+<p><img alt="" src="https://mdn.mozillademos.org/files/14637/1_Grid_Track.png" style="height: 261px; width: 392px;"></p>
+
+<p>До попереднього прикладу можна додати властивість  <code>grid-template-columns</code>, визначаючи розмір смуг-стовпчиків.</p>
+
+<p>Таким чином створено grid-сітку з трьома смугами-стовпчиками шириною по 200 рх. Дочірні елементи вкладатимуться в цю grid-сітку в кожну клітинку. </p>
+
+<div id="grid_first">
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div&gt;One&lt;/div&gt;
+ &lt;div&gt;Two&lt;/div&gt;
+ &lt;div&gt;Three&lt;/div&gt;
+ &lt;div&gt;Four&lt;/div&gt;
+ &lt;div&gt;Five&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: 200px 200px 200px;
+}
+</pre>
+
+<div class="hidden">
+<pre class="brush: css line-numbers language-css"><code class="language-css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.wrapper &gt; div {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}</code></pre>
+</div>
+
+<p>{{ EmbedLiveSample('grid_first', '610', '140') }}</p>
+</div>
+
+<h3 id="Одиниця_fr">Одиниця fr </h3>
+
+<p>Смуги визначаються одиницями довжини. Grid-сітка має додаткову одиницю довжини яка допомагає створювати гнучкі grid-смуги. Одиниця <code>fr</code>  являє собою частку вільного простору в  grid-контейнері. Наступна сітка створює три рівних по ширині смуги які  стають більше і менше відповідно наявному простору. </p>
+
+<div id="fr_unit_ls">
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div&gt;One&lt;/div&gt;
+ &lt;div&gt;Two&lt;/div&gt;
+ &lt;div&gt;Three&lt;/div&gt;
+ &lt;div&gt;Four&lt;/div&gt;
+ &lt;div&gt;Five&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: 1fr 1fr 1fr;
+}
+</pre>
+
+<div class="hidden">
+<pre class="brush: css line-numbers language-css"><code class="language-css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.wrapper &gt; div {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}</code></pre>
+</div>
+
+<p>{{ EmbedLiveSample('fr_unit_ls', '220', '140') }}</p>
+</div>
+
+<p>В наступному прикладі ми створюємо визначення з <code>2fr</code> смугою і дві <code>1fr</code> смуги. Доступний простір розділений на чотири частини, дві з яких надаються першій смузі і по одній частині кожній з наступних двох.</p>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: 2fr 1fr 1fr;
+}
+</pre>
+
+<p>В останньому прикладі ми комбінуємо абсолютні одиниці ширини смуг з фракційними. Перша смуга  500 px, фіксована ширина відбирається з доступного простору. Решта простору ділиться на три і призначається двом гнучким смугам пропорційно. </p>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: 500px 1fr 2fr;
+}
+</pre>
+
+<h3 id="Визначення_смуг_зі_значенням_repeat()"><code>Визначення смуг зі значенням repeat()</code></h3>
+
+<p>Великі grid-сітки з багатьма стугами можуть використовувати значення <code>repeat()</code> для скорочення при визначенні стовпчиків: </p>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: 1fr 1fr 1fr;
+}
+</pre>
+
+<p>Також може бути записано як:</p>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+}
+</pre>
+
+<p>Значення repeat може використовуватись лише для частини стовпчиків. В наступному прикладі ініційовано смугу 20 рх, секцію з 6 смуг шириною <code>1fr,</code> і смугу 20 рх. </p>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: 20px repeat(6, 1fr) 20px;
+}
+</pre>
+
+<p>Значення repeat визначає смуги, тобто його можливо використовувати для створення цілих шаблонів стовпчиків. В наступному прикладі grid-сітка складається з 10 смуг. Смуга <code>1fr</code> , смуга <code>2fr</code> і так п'ять разів.</p>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(5, 1fr 2fr);
+}
+</pre>
+
+<h3 id="Неявна_і_явна_Grid-сітка">Неявна і явна Grid-сітка</h3>
+
+<p>Cтворюючи Grid-сітку нашого прикладу, ми визначили стовпчики-смуги властивістю {{cssxref("grid-template-columns")}}, але дозволимо grid-сітці створювати рядки так, як краще для контенту. Такі рядки створюються в неявній grid-сітці. Явна grid-сітка складається з рядків і стовпчиків, які визначаються властивостями  {{cssxref("grid-template-columns")}} та {{cssxref("grid-template-rows")}}.</p>
+
+<p>Якщо ми розташовуємо щось поза цією grid-сіткою, або кількість вмісту потребує більше grid смуг, тоді  grid-сітка створює рядки і стовпчики в неявній  grid-сітці. Такі смуги матимуть авторозмір за замовчуванням якраз щоб вмістити свій контент.</p>
+
+<p>Ви також можете визначити встановлений розмір для смуг, створених в неявній grid-сітці властивостями {{cssxref("grid-auto-rows")}} та {{cssxref("grid-auto-columns")}}.</p>
+
+<p>В прикладі нижче ми використовуємо <code>grid-auto-rows</code>  щоб забезпечити неявне створення смуги висотою 200 рх.</p>
+
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div&gt;One&lt;/div&gt;
+ &lt;div&gt;Two&lt;/div&gt;
+ &lt;div&gt;Three&lt;/div&gt;
+ &lt;div&gt;Four&lt;/div&gt;
+ &lt;div&gt;Five&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ grid-auto-rows: 200px;
+}
+</pre>
+
+<div class="hidden">
+<pre class="brush: css line-numbers language-css"><code class="language-css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.wrapper &gt; div {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}</code></pre>
+</div>
+
+<p>{{ EmbedLiveSample('The_implicit_and_explicit_grid', '230', '420') }}</p>
+
+<h3 id="Розміри_смуги_і_minmax()">Розміри смуги і <code>minmax()</code></h3>
+
+<p>Встановлюючи явну grid-сітку або визначаючи розміри для автоматично створених рядків або стовпчиків може виникнути необхідність надання смугам мінімального розміру. Але треба переконатись що розширюючись, вони відповідатимуть будь якому доданому контенту. Наприклад ми хочемо щоб рядки ніколи не були менше 100 рх, але якщо контент розширюється до 300 рх, ми б хотіли щоб рядок розширився до такої висоти. </p>
+
+<p>Grid для таких випадків має функцію {{cssxref("minmax", "minmax()")}}. В наступному прикладі я використовую <code>minmax()</code>в значенні {{cssxref("grid-auto-rows")}}. Це означає, що автоматично створені рядки матимуть мінімальну висоту 100 рх, а максимальну <code>auto</code>. Використання <code>auto</code> означає, що розмір буде підлаштовуватись під розмір контенту таким чином, щоб вмістити найвищий елемент в цьому рядку.</p>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ grid-auto-rows: minmax(100px, auto);
+}
+</pre>
+
+<div class="hidden">
+<pre class="brush: css line-numbers language-css"><code class="language-css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.wrapper &gt; div {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}</code></pre>
+</div>
+
+<pre class="brush: html line-numbers language-html"><code class="language-html">&lt;div class="wrapper"&gt;
+ &lt;div&gt;One&lt;/div&gt;
+ &lt;div&gt;Two
+ &lt;p&gt;I have some more content in.&lt;/p&gt;
+ &lt;p&gt;This makes me taller than 100 pixels.&lt;/p&gt;
+ &lt;/div&gt;
+ &lt;div&gt;Three&lt;/div&gt;
+ &lt;div&gt;Four&lt;/div&gt;
+ &lt;div&gt;Five&lt;/div&gt;
+&lt;/div&gt;</code></pre>
+
+<p>{{ EmbedLiveSample('Track_sizing_and_minmax()', '240', '470') }}</p>
+
+<h2 id="Grid_Лінії">Grid Лінії</h2>
+
+<p>Варто зауважити що коли ми визначаємо Grid, ми визначаємо grid-смуги (але не grid-лінії). В такому випадку Grid дає нам нумеровані лінії для позиціонування елементів. В прикладі нижче Grid має 3 стовпчика, 2 рядки і 4 вертикальних лінії.</p>
+
+<p><img alt="Diagram showing numbered grid lines." src="https://mdn.mozillademos.org/files/14761/1_diagram_numbered_grid_lines.png" style="height: 456px; width: 764px;"></p>
+
+<p>Лінії пронумеровано згідно способу нумерації документа: зліва направо і зверху вниз (якщо на мові що викоричтовується пишуть справа наліво, то і нумерація ліній справа наліво). Лінії також можуть бути поіменовані.</p>
+
+<h3 id="Позиціонування_елементів_по_лініях">Позиціонування елементів по лініях</h3>
+
+<p>Наступний приклад демонструє просте позиціонування елементів по лініях. При розміщенні елементів ми надаємо перевагу більше лініям ніж смугам.</p>
+
+<p>В наступному прикладі ми розміщуємо перші два елементи на Grid-cітці, яка складається з трьох смуг-стовпчиків, застосовуючи властивості {{cssxref("grid-column-start")}}, {{cssxref("grid-column-end")}}, {{cssxref("grid-row-start")}} та {{cssxref("grid-row-end")}}.  Рухаючись зліва направо, перший елемент починається з вертикальної лініі 1 і простягається до вертикальної лініі 4, що праворуч нашої Grid-сітки. Він починається на горизонтальній лінії 1 і закінчується на горизонтальній лінії 3, тобто займає два рядка смуг.</p>
+
+<p>Другий елемент починається з вертикальної лініі 1, і простягається на одну смугу. Це за замовчуванням, тому можна не вказувати кінцеву лінію. Також по рядках він простягається з горизонтальній лінії 3 до горизонтальній лінії 5. Інші елементи розміщуються в порожніх просторах на Grid-сітці.</p>
+
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div class="box1"&gt;One&lt;/div&gt;
+ &lt;div class="box2"&gt;Two&lt;/div&gt;
+ &lt;div class="box3"&gt;Three&lt;/div&gt;
+ &lt;div class="box4"&gt;Four&lt;/div&gt;
+ &lt;div class="box5"&gt;Five&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ grid-auto-rows: 100px;
+}
+.box1 {
+ grid-column-start: 1;
+ grid-column-end: 4;
+ grid-row-start: 1;
+ grid-row-end: 3;
+}
+.box2 {
+ grid-column-start: 1;
+ grid-row-start: 3;
+ grid-row-end: 5;
+}
+</pre>
+
+<div class="hidden">
+<pre class="brush: css line-numbers language-css"><code class="language-css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.wrapper &gt; div {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}</code></pre>
+</div>
+
+<p>{{ EmbedLiveSample('Positioning_items_against_lines', '230', '420') }}</p>
+
+<p>Не забуваймо, що можна використовувати <a href="/en-US/docs/Tools/Page_Inspector/How_to/Examine_grid_layouts">Grid Inspector</a> в Firefox Developer Tools щоб побачити як елементи позиціонуються на лініях Grid-сітки.</p>
+
+<h2 id="Grid-клітини">Grid-клітини</h2>
+
+<p><em>Grid-клітина</em> – найменша одиниця Grid-сітки, по аналогії з чарунком таблиці. Як ми бачили в попередніх прикладах, якщо Grid-сітка визначена як батьківська, дочірні елементи лежатимуть по одному в кожній її клітині. На зображенні кольором позначено першу клітину Grid-сітки.</p>
+
+<p><img alt="The first cell of the grid highlighted" src="https://mdn.mozillademos.org/files/14643/1_Grid_Cell.png" style="height: 233px; width: 350px;"></p>
+
+<h2 id="Grid-ділянки">Grid-ділянки</h2>
+
+<p>Елементи можуть розташовуватись на одній або декількох клітинках як в рядок так і в стовпчик, і це створює Grid-ділянки. Grid-ділянки завжди прямокутні, неможлива, наприклад, L-подібна Grid-ділянка. На зображенні Grid-ділянка займає два рядки і два стовпчики.</p>
+
+<p><img alt="A grid area" src="https://mdn.mozillademos.org/files/14645/1_Grid_Area.png" style="height: 238px; width: 357px;"></p>
+
+<h2 id="Розриви">Розриви</h2>
+
+<p><em>Розриви</em> між Grid-клітинами створюються властивістями {{cssxref("grid-column-gap")}} та {{cssxref("grid-row-gap")}}, або скорочено {{cssxref("grid-gap")}}. В наступному прикладі створюється проміжок у 10рх між стовпчиками та проміжок <code>1em</code> між рядками. </p>
+
+<pre class="brush: css line-numbers language-css"><code class="language-css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ column-gap: 10px;
+ row-gap: 1em;
+}</code></pre>
+
+<div class="note">
+<p><strong>Примітка:</strong> Коли гріди тільки почали використовуватись браузерами {{cssxref("column-gap")}}, {{cssxref("row-gap")}} та {{cssxref("gap")}} мали префікси <code>grid-</code> як от {{cssxref("grid-column-gap")}}, {{cssxref("grid-row-gap")}} та {{cssxref("grid-gap")}} відповідно.</p>
+
+<p>Браузери наразі оновлюються, щоб видалити цей префікс, проте попередньо встановлені версії також будуть підтримуватися як псевдоніми, що робить їх безпечними для використання. В даний час деякі веб-переглядачі не підтримують безпрефіксний варіант, тому в прикладах цього посібника використовуюється версія з grid- префіксом.</p>
+</div>
+
+<pre class="brush: html line-numbers language-html"><code class="language-html">&lt;div class="wrapper"&gt;
+ &lt;div&gt;One&lt;/div&gt;
+ &lt;div&gt;Two&lt;/div&gt;
+ &lt;div&gt;Three&lt;/div&gt;
+ &lt;div&gt;Four&lt;/div&gt;
+ &lt;div&gt;Five&lt;/div&gt;
+&lt;/div&gt;</code></pre>
+
+<div class="hidden">
+<pre class="brush: css line-numbers language-css"><code class="language-css">* {box-sizing: border-box;}
+
+.wrapper {
+ grid-column-gap: 10px;
+ grid-row-gap: 1em;
+
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.wrapper &gt; div {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}</code></pre>
+</div>
+
+<p>{{ EmbedLiveSample('Gutters') }}</p>
+
+<p>Будь-який простір, відведений на розриви, буде враховуватись до відведення простору для гнучких <code>fr</code> довжин смуг. Розриви використовуваються в розмітці, як звичайні grid-смуги, за виключенням того, що ви не зможете в них нічого помістити. З точки зору лінійного позиціонування розрив діє як товста лінія.</p>
+
+<h2 id="Вкладені_Grid-сітки">Вкладені Grid-сітки</h2>
+
+<p>Grid-елементи можуть ставати Grid-контейнерами. В попередньому прикладі ми створили Grid-сітку з трьох стовпчиків з двома позиціонованими елементами.  Перший з них має піделементи. Оскільки ці елементи не є прямими нащадками, вони не беруть участі в  Grid-розкладці і відображаються в нормальному потоці. </p>
+
+<div id="nesting">
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div class="box box1"&gt;
+ &lt;div class="nested"&gt;a&lt;/div&gt;
+ &lt;div class="nested"&gt;b&lt;/div&gt;
+ &lt;div class="nested"&gt;c&lt;/div&gt;
+  &lt;/div&gt;
+ &lt;div class="box box2"&gt;Two&lt;/div&gt;
+ &lt;div class="box box3"&gt;Three&lt;/div&gt;
+ &lt;div class="box box4"&gt;Four&lt;/div&gt;
+ &lt;div class="box box5"&gt;Five&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<p><img alt="Nested grid in flow" src="https://mdn.mozillademos.org/files/14641/1_Nested_Grids_in_flow.png" style="height: 512px; width: 900px;"></p>
+
+<p>Якщо застосувати <code>display: grid</code> до <code>box1</code>, то ця Grid-смуга також стане Grid-сіткою. А елементи, що в ній містяться, надалі розташовуватимуться на цій новій Grid-сітці.</p>
+
+<pre class="brush: css line-numbers language-css"><code class="language-css">.box1 {
+ grid-column-start: 1;
+ grid-column-end: 4;
+ grid-row-start: 1;
+ grid-row-end: 3;
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+}</code></pre>
+
+<div class="hidden">
+<pre class="brush: css line-numbers language-css"><code class="language-css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+}
+
+.box {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}
+
+.box1 {
+ grid-column: 1 / 4;
+}
+
+.nested {
+ border: 2px solid #ffec99;
+ border-radius: 5px;
+ background-color: #fff9db;
+ padding: 1em;
+}</code></pre>
+</div>
+</div>
+
+<p>{{ EmbedLiveSample('nesting', '600', '340') }}</p>
+
+<p>В цьому випадку, дочірня сітка немає відношення до батьківської. Як ви можете бачити на прикладі, вона не наслідує батьківськи {{cssxref("grid-gap")}}, а також лінії дочірньої сітки не вирівнюються по лініях батьківської сітки.</p>
+
+<h3 id="Під-сітка">Під-сітка</h3>
+
+<p>У робочій чорнетці специфікації Grid Level 2 є функція під назвою <em>subgrid</em>, яка має дозволити нам створювати вкладені сітки, які б використовували визначення смуги батьківської сітки.</p>
+
+<div class="note">
+<p><strong>Примітка:</strong> під-сітки ще не реалізовані в жодному браузері, і їхня специфікація ще може змінюватися.</p>
+</div>
+
+<p>У поточній специфікації ми відредагуємо вищезгаданий приклад вкладеної Grid-сітки, змінивши визначення смуги з <code>grid-template-columns: repeat(3, 1fr)</code> , на <code>grid-template-columns: subgrid</code>. Вкладена сітка надалі використовуватиме батьківські Grid-смуги до елементів макета.</p>
+
+<pre class="brush: css line-numbers language-css"><code class="language-css">.box1 {
+ grid-column-start: 1;
+ grid-column-end: 4;
+ grid-row-start: 1;
+ grid-row-end: 3;
+ display: grid;
+ grid-template-columns: subgrid;
+}</code></pre>
+
+<h2 id="Нашарування_елементів_за_допомогою_z-index">Нашарування елементів за допомогою <code>z-index</code></h2>
+
+<p>Grid-елементи можуть займати одну і ту ж саму клітину. Якщо повернутись до нашого прикладу з елементами, що розташовані за номером рядка, ми можемо змінити його так, щоб два елементи перекривали один одного.</p>
+
+<div id="l_ex">
+<pre class="brush: html line-numbers language-html"><code class="language-html">&lt;div class="wrapper"&gt;
+ &lt;div class="box box1"&gt;One&lt;/div&gt;
+ &lt;div class="box box2"&gt;Two&lt;/div&gt;
+ &lt;div class="box box3"&gt;Three&lt;/div&gt;
+ &lt;div class="box box4"&gt;Four&lt;/div&gt;
+ &lt;div class="box box5"&gt;Five&lt;/div&gt;
+&lt;/div&gt;</code></pre>
+
+<pre class="brush: css line-numbers language-css"><code class="language-css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ grid-auto-rows: 100px;
+}
+
+.box1 {
+ grid-column-start: 1;
+ grid-column-end: 4;
+ grid-row-start: 1;
+ grid-row-end: 3;
+}
+
+.box2 {
+ grid-column-start: 1;
+ grid-row-start: 2;
+ grid-row-end: 4;
+}</code></pre>
+
+<div class="hidden">
+<pre class="brush: css line-numbers language-css"><code class="language-css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.box {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}</code>
+</pre>
+</div>
+</div>
+
+<p>{{ EmbedLiveSample('l_ex', '230', '420') }}</p>
+
+<p>Елемент <code>box2</code> тепер перекриває <code>box1</code>, він відображається зверху, тому що пізніше трапляеться в коді документу.</p>
+
+<h3 id="Керування_послідовністю">Керування послідовністю</h3>
+
+<p>Ми можемо контролювати порядок, в якому елементи накладаються один на одного, використовуючи властивість <code>z-index</code>. Якщо надати <code>box2</code> нижчий <code>z-index</code>, ніж в <code>box1</code>, то він і буде показаний нижче у стеці.</p>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ grid-auto-rows: 100px;
+}
+
+.box1 {
+ grid-column-start: 1;
+ grid-column-end: 4;
+ grid-row-start: 1;
+ grid-row-end: 3;
+ z-index: 2;
+}
+
+.box2 {
+ grid-column-start: 1;
+ grid-row-start: 2;
+ grid-row-end: 4;
+ z-index: 1;
+}
+</pre>
+
+<div class="hidden">
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div class="box box1"&gt;One&lt;/div&gt;
+ &lt;div class="box box2"&gt;Two&lt;/div&gt;
+ &lt;div class="box box3"&gt;Three&lt;/div&gt;
+ &lt;div class="box box4"&gt;Four&lt;/div&gt;
+ &lt;div class="box box5"&gt;Five&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css line-numbers language-css"><code class="language-css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.box {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}</code></pre>
+</div>
+
+<p>{{ EmbedLiveSample('Controlling_the_order', '230', '420') }}</p>
+
+<h2 id="Наступні_кроки">Наступні кроки</h2>
+
+<p>У цій статті ми швидко переглянули специфікацію Grid Layout. Пограйте з прикладами коду, а потім переходьте до <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Relationship_of_Grid_Layout">наступної частини цього посібника, де ми насправді почнемо заглиблюватись в деталі CSS Grid Layout</a>.</p>
+
+<section class="Quick_links" id="Quick_Links">
+<ol>
+ <li><a href="/en-US/docs/Web/CSS"><strong>CSS</strong></a></li>
+ <li><a href="/en-US/docs/Web/CSS/Reference"><strong>CSS Reference</strong></a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout">CSS Grid Layout</a></li>
+ <li data-default-state="open"><a href="#"><strong>Guides</strong></a>
+ <ol>
+ <li><a href="/uk/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout">Basics concepts of grid layout</a></li>
+ <li><a href="/uk/docs/Web/CSS/CSS_Grid_Layout/Relationship_of_Grid_Layout">Relationship to other layout methods</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Line-based_Placement_with_CSS_Grid">Line-based placement</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Grid_Template_Areas">Grid template areas</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Layout_using_Named_Grid_Lines">Layout using named grid lines</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Auto-placement_in_CSS_Grid_Layout">Auto-placement in grid layout</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Box_Alignment_in_CSS_Grid_Layout">Box alignment in grid layout</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid,_Logical_Values_and_Writing_Modes">Grids, logical values and writing modes</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid_Layout_and_Accessibility">CSS Grid Layout and Accessibility</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid_and_Progressive_Enhancement">CSS Grid Layout and Progressive Enhancement</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Realizing_common_layouts_using_CSS_Grid_Layout">Realizing common layouts using grids</a></li>
+ </ol>
+ </li>
+ <li data-default-state="open"><a href="#"><strong>Properties</strong></a>
+ <ol>
+ <li><a href="/en-US/docs/Web/CSS/grid">grid</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-area">grid-area</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-auto-columns">grid-auto-columns</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-auto-flow">grid-auto-flow</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-auto-rows">grid-auto-rows</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column">grid-column</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column-end">grid-column-end</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column-gap">grid-column-gap</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column-start">grid-column-start</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-gap">grid-gap</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row">grid-row</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row-end">grid-row-end</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row-gap">grid-row-gap</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row-start">grid-row-start</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template">grid-template</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template-areas">grid-template-areas</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template-columns">grid-template-columns</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template-rows">grid-template-rows</a></li>
+ </ol>
+ </li>
+ <li data-default-state="open"><a href="#"><strong>Glossary</strong></a>
+ <ol>
+ <li><a href="/en-US/docs/Glossary/Grid">Grid</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_lines">Grid lines</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_tracks">Grid tracks</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_cell">Grid cell</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_areas">Grid areas</a></li>
+ <li><a href="/en-US/docs/Glossary/Gutters">Gutters</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_Axis">Grid Axis</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_rows">Grid row</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_column">Grid column</a></li>
+ </ol>
+ </li>
+</ol>
+</section>
diff --git a/files/uk/web/css/css_grid_layout/index.html b/files/uk/web/css/css_grid_layout/index.html
new file mode 100644
index 0000000000..e403f8364f
--- /dev/null
+++ b/files/uk/web/css/css_grid_layout/index.html
@@ -0,0 +1,245 @@
+---
+title: CSS Grid Layout
+slug: Web/CSS/CSS_Grid_Layout
+tags:
+ - CSS
+ - Grid Layout
+ - Grids
+ - Layout
+ - NeedsTranslation
+ - Overview
+ - Reference
+ - TopicStub
+translation_of: Web/CSS/CSS_Grid_Layout
+---
+<p><strong>CSS Grid layout</strong> відзначається тим, що розділяє сторінку на ділянки чи задає співвідношення між елементами, побудованими з HTML примітивів, з точки зору розміру, положення та слоїв.</p>
+
+<p>Подібно до таблиць, CSS Grid дозволяє автору вирівнювати елементи у стовпчиках та рядках. Однак, CSS Grid, в порівнянні з таблицями, надає більше можливостей і полегшує створення макетів. Наприклад, дочірні елементи Grid-контейнера можуть перекривати один одного і нашаровуватись, подібно до позиційованих CSS елементів.</p>
+
+<h2 id="Basic_Example" name="Basic_Example">Базовий приклад</h2>
+
+<p><span id="result_box" lang="uk"><span>У наведеному нижче прикладі показана сітка з трьома стовпчиками, в якій нові рядки мають мінімальну висоту 100 пікселів, а максимальна висота вираховується автоматично.</span> <span>Елементи розміщені в сітці використовуючи лінійне розташування .</span></span></p>
+
+<div id="example">
+<div class="hidden">
+<pre class="brush: css notranslate">* {box-sizing: border-box;}
+.wrapper {
+ max-width: 940px;
+ margin: 0 auto;
+}
+
+.wrapper &gt; div {
+ border: 2px solid rgb(233,171,88);
+ border-radius: 5px;
+ background-color: rgba(233,171,88,.5);
+ padding: 1em;
+ color: #d9480f;
+}</pre>
+</div>
+
+<h3 id="HTML">HTML</h3>
+
+<pre class="brush: html notranslate">&lt;div class="wrapper"&gt;
+ &lt;div class="one"&gt;One&lt;/div&gt;
+ &lt;div class="two"&gt;Two&lt;/div&gt;
+ &lt;div class="three"&gt;Three&lt;/div&gt;
+ &lt;div class="four"&gt;Four&lt;/div&gt;
+ &lt;div class="five"&gt;Five&lt;/div&gt;
+ &lt;div class="six"&gt;Six&lt;/div&gt;
+&lt;/div&gt;</pre>
+
+<h3 id="CSS">CSS</h3>
+
+<pre class="brush: css notranslate">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ grid-gap: 10px;
+ grid-auto-rows: minmax(100px, auto);
+}
+.one {
+ grid-column: 1 / 3;
+ grid-row: 1;
+}
+.two {
+ grid-column: 2 / 4;
+ grid-row: 1 / 3;
+}
+.three {
+ grid-column: 1;
+ grid-row: 2 / 5;
+}
+.four {
+ grid-column: 3;
+ grid-row: 3;
+}
+.five {
+ grid-column: 2;
+ grid-row: 4;
+}
+.six {
+ grid-column: 3;
+ grid-row: 4;
+}
+</pre>
+
+<p>{{ EmbedLiveSample('example', '500', '440') }}</p>
+</div>
+
+<h2 id="Посилання">Посилання</h2>
+
+<h3 id="CSS_властивості">CSS властивості</h3>
+
+<div class="index">
+<ul>
+ <li>{{cssxref("grid-template-columns")}}</li>
+ <li>{{cssxref("grid-template-rows")}}</li>
+ <li>{{cssxref("grid-template-areas")}}</li>
+ <li>{{cssxref("grid-template")}}</li>
+ <li>{{cssxref("grid-auto-columns")}}</li>
+ <li>{{cssxref("grid-auto-rows")}}</li>
+ <li>{{cssxref("grid-auto-flow")}}</li>
+ <li>{{cssxref("grid")}}</li>
+ <li>{{cssxref("grid-row-start")}}</li>
+ <li>{{cssxref("grid-column-start")}}</li>
+ <li>{{cssxref("grid-row-end")}}</li>
+ <li>{{cssxref("grid-column-end")}}</li>
+ <li>{{cssxref("grid-row")}}</li>
+ <li>{{cssxref("grid-column")}}</li>
+ <li>{{cssxref("grid-area")}}</li>
+ <li>{{cssxref("grid-row-gap")}}</li>
+ <li>{{cssxref("grid-column-gap")}}</li>
+ <li>{{cssxref("grid-gap")}}</li>
+</ul>
+</div>
+
+<h3 id="CSS_функції">CSS функції</h3>
+
+<div class="index">
+<ul>
+ <li>{{cssxref("repeat", "repeat()")}}</li>
+ <li>{{cssxref("minmax", "minmax()")}}</li>
+ <li>{{cssxref("fit-content", "fit-content()")}}</li>
+</ul>
+</div>
+
+<h3 id="Глосарій">Глосарій</h3>
+
+<div class="index">
+<ul>
+ <li><a href="/en-US/docs/Glossary/Grid">Grid</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_Lines">Grid Lines</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_Tracks">Grid Tracks</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_Cell">Grid Cell</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_Areas">Grid Area</a></li>
+ <li><a href="/en-US/docs/Glossary/Gutters">Gutters</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_Axis">Grid Axis</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_Rows">Grid row</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_Column">Grid column</a></li>
+</ul>
+</div>
+
+<h2 id="Посібники">Посібники</h2>
+
+<div class="index">
+<ul>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout">Basic concepts of Grid Layout</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Relationship_of_Grid_Layout">Relationship of Grid Layout to other layout methods</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Line-based_Placement_with_CSS_Grid">Layout using line-based placement</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Grid_Template_Areas">Grid template areas</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Layout_using_Named_Grid_Lines">Layout using named grid lines</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Auto-placement_in_CSS_Grid_Layout">Auto-placement in CSS Grid Layout</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Box_Alignment_in_CSS_Grid_Layout">Box alignment in CSS Grid Layout</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid,_Logical_Values_and_Writing_Modes">CSS Grid, Logical Values and Writing Modes</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid_Layout_and_Accessibility">CSS Grid Layout and accessibility</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid_and_Progressive_Enhancement">CSS Grid and progressive enhancement</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Realising_common_layouts_using_CSS_Grid_">Realising common layouts using CSS Grid</a></li>
+</ul>
+</div>
+
+<h2 id="Зовнішні_ресурси">Зовнішні ресурси</h2>
+
+<ul>
+ <li><a href="http://labs.jensimmons.com/">Examples from Jen Simmons</a></li>
+ <li><a href="http://gridbyexample.com/">Grid by Example - a collection of usage examples and video tutorials</a></li>
+ <li><a href="https://tympanus.net/codrops/css_reference/grid/">Codrops Grid Reference</a></li>
+ <li><a href="https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Examine_grid_layouts">Firefox DevTools CSS Grid Inspector</a></li>
+ <li><a href="https://mozilladevelopers.github.io/playground/">CSS Grid Playground</a></li>
+ <li><a href="http://cssgridgarden.com">Grid Garden</a> - Гра для вивчення CSS grid</li>
+</ul>
+
+<h2 id="Специфікації">Специфікації</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{ SpecName('CSS3 Grid') }}</td>
+ <td>{{ Spec2('CSS3 Grid') }}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<section class="Quick_links" id="Quick_Links">
+<ol>
+ <li><a href="/en-US/docs/Web/CSS"><strong>CSS</strong></a></li>
+ <li><a href="/en-US/docs/Web/CSS/Reference"><strong>CSS Reference</strong></a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout">CSS Grid Layout</a></li>
+ <li data-default-state="open"><a href="#"><strong>Guides</strong></a>
+ <ol>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout">Basics concepts of grid layout</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Relationship_of_Grid_Layout">Relationship to other layout methods</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Line-based_Placement_with_CSS_Grid">Line-based placement</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Grid_Template_Areas">Grid template areas</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Layout_using_Named_Grid_Lines">Layout using named grid lines</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Auto-placement_in_CSS_Grid_Layout">Auto-placement in grid layout</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Box_Alignment_in_CSS_Grid_Layout">Box alignment in grid layout</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid,_Logical_Values_and_Writing_Modes">Grids, logical values and writing modes</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid_Layout_and_Accessibility">CSS Grid Layout and Accessibility</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid_and_Progressive_Enhancement">CSS Grid Layout and Progressive Enhancement</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Realizing_common_layouts_using_CSS_Grid_Layout">Realizing common layouts using grids</a></li>
+ </ol>
+ </li>
+ <li data-default-state="open"><a href="#"><strong>Properties</strong></a>
+ <ol>
+ <li><a href="/en-US/docs/Web/CSS/grid">grid</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-area">grid-area</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-auto-columns">grid-auto-columns</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-auto-flow">grid-auto-flow</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-auto-rows">grid-auto-rows</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column">grid-column</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column-end">grid-column-end</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column-gap">grid-column-gap</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column-start">grid-column-start</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-gap">grid-gap</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row">grid-row</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row-end">grid-row-end</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row-gap">grid-row-gap</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row-start">grid-row-start</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template">grid-template</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template-areas">grid-template-areas</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template-columns">grid-template-columns</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template-rows">grid-template-rows</a></li>
+ </ol>
+ </li>
+ <li data-default-state="open"><a href="#"><strong>Glossary</strong></a>
+ <ol>
+ <li><a href="/en-US/docs/Glossary/Grid">Grid</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_lines">Grid lines</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_tracks">Grid tracks</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_cell">Grid cell</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_areas">Grid areas</a></li>
+ <li><a href="/en-US/docs/Glossary/Gutters">Gutters</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_Axis">Grid Axis</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_rows">Grid row</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_column">Grid column</a></li>
+ </ol>
+ </li>
+</ol>
+</section>
diff --git a/files/uk/web/css/css_grid_layout/relationship_of_grid_layout/index.html b/files/uk/web/css/css_grid_layout/relationship_of_grid_layout/index.html
new file mode 100644
index 0000000000..7f715c0986
--- /dev/null
+++ b/files/uk/web/css/css_grid_layout/relationship_of_grid_layout/index.html
@@ -0,0 +1,628 @@
+---
+title: Relationship of grid layout to other layout methods
+slug: Web/CSS/CSS_Grid_Layout/Relationship_of_Grid_Layout
+translation_of: Web/CSS/CSS_Grid_Layout/Relationship_of_Grid_Layout
+---
+<p>CSS Grid Layout has been designed to work alongside other parts of CSS, as part of a complete system for doing the layout. In this guide, I will explain how a grid fits together with other techniques you may already be using.</p>
+
+<h2 id="Grid_and_flexbox">Grid and flexbox</h2>
+
+<p>The basic difference between CSS Grid Layout and <a href="/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout">CSS Flexbox Layout</a> is that flexbox was designed for layout in one dimension - either a row <em>or</em> a column. Grid was designed for two-dimensional layout - rows, and columns at the same time. The two specifications share some common features, however, and if you have already learned how to use flexbox, the similarities should help you get to grips with Grid.</p>
+
+<h3 id="Одновимірні_макети_проти_двовимірних">Одновимірні макети проти двовимірних</h3>
+
+<p>A simple example can demonstrate the difference between one- and two-dimensional layouts.</p>
+
+<p>In this first example, I am using flexbox to lay out a set of boxes. I have five child items in my container, and I have given the flex properties values so that they can grow and shrink from a flex-basis of 200 pixels.</p>
+
+<p>I have also set the {{cssxref("flex-wrap")}} property to <code>wrap</code>, so that if the space in the container becomes too narrow to maintain the flex basis, items will wrap onto a new row.</p>
+
+<div id="onedtwod">
+<div class="hidden">
+<pre class="brush: css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.wrapper &gt; div {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}
+</pre>
+</div>
+
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div&gt;One&lt;/div&gt;
+ &lt;div&gt;Two&lt;/div&gt;
+ &lt;div&gt;Three&lt;/div&gt;
+ &lt;div&gt;Four&lt;/div&gt;
+ &lt;div&gt;Five&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">.wrapper {
+ display: flex;
+ flex-wrap: wrap;
+}
+.wrapper &gt; div {
+ flex: 1 1 200px;
+}
+</pre>
+</div>
+
+<p>{{ EmbedLiveSample('onedtwod', '500', '230') }}</p>
+
+<p>In the image, you can see that two items have wrapped onto a new line. These items are sharing the available space and not lining up underneath the items above. This is because when you wrap flex items, each new row (or column when working by column) becomes a new flex container. Space distribution happens across the row.</p>
+
+<p>A common question then is how to make those items line up. This is where you want a two-dimensional layout method: You want to control the alignment by row and column, and this is where grid comes in.</p>
+
+<h3 id="The_same_layout_with_CSS_grids">The same layout with CSS grids</h3>
+
+<p>In this next example, I create the same layout using Grid. This time we have three <code>1fr</code> column tracks. We do not need to set anything on the items themselves; they will lay themselves out one into each cell of the created grid. As you can see they stay in a strict grid, lining up in rows and columns. With five items, we get a gap on the end of row two.</p>
+
+<div class="Two_Dimensional_With_Grid">
+<div class="hidden">
+<pre class="brush: css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.wrapper &gt; div {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}
+</pre>
+</div>
+
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div&gt;One&lt;/div&gt;
+ &lt;div&gt;Two&lt;/div&gt;
+ &lt;div&gt;Three&lt;/div&gt;
+ &lt;div&gt;Four&lt;/div&gt;
+ &lt;div&gt;Five&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+}
+</pre>
+
+<p>{{ EmbedLiveSample('Two_Dimensional_With_Grid', '300', '170') }}</p>
+</div>
+
+<p>A simple question to ask yourself when deciding between grid or flexbox is:</p>
+
+<ul>
+ <li>do I only need to control the layout by row <u><em>or</em></u> column – use a flexbox</li>
+ <li>do I need to control the layout by row <u><em>and</em></u> column – use a grid</li>
+</ul>
+
+<h3 id="Content_out_or_layout_in">Content out or layout in?</h3>
+
+<p>In addition to the one-dimensional versus two-dimensional distinction, there is another way to decide if you should use flexbox or grid for a layout. Flexbox works from the content out. An ideal use case for flexbox is when you have a set of items and want to space them out evenly in a container. You let the size of the content decide how much individual space each item takes up. If the items wrap onto a new line, they will work out their spacing based on their size and the available space <em>on that line</em>.</p>
+
+<p>Grid works from the layout in. When you use CSS Grid Layout you create a layout and then you place items into it, or you allow the auto-placement rules to place the items into the grid cells according to that strict grid. It is possible to create tracks that respond to the size of the content, however, they will also change the entire track.</p>
+
+<p>If you are using flexbox and find yourself disabling some of the flexibility, you probably need to use CSS Grid Layout. An example would be if you are setting a percentage width on a flex item to make it line up with other items in a row above. In that case, a grid is likely to be a better choice.</p>
+
+<h3 id="Box_alignment">Box alignment</h3>
+
+<p>The feature of flexbox that was most exciting to many of us was that it gave us proper alignment control for the first time. It made it easy to center a box on the page. Flex items can stretch to the height of the flex container, meaning that equal height columns were possible. These were things we have wanted to do for a very long time, and have come up with all kinds of hacks to at least create the visual effect of.</p>
+
+<p>The alignment properties from the flexbox specification have been added to a new specification called <a href="https://drafts.csswg.org/css-align/">Box Alignment Level 3</a>. This means that they can be used in other specifications, including Grid Layout. In the future, they may well apply to other layout methods as well.</p>
+
+<p>In a later guide in this series, I’ll be taking a proper look at Box Alignment and how it works in Grid Layout. For now, here is a comparison between simple examples of flexbox and grid.</p>
+
+<p>In the first example, which uses flexbox, I have a container with three items inside. The wrapper {{cssxref("min-height")}} is set, so it defines the height of the flex container. I have set {{cssxref("align-items")}} on the flex container to <code>flex-end</code> so the items will line up at the end of the flex container. I have also set the {{cssxref("align-self")}} property on <code>box1</code> so it will override the default and stretch to the height of the container and on <code>box2</code> so it aligns to the start of the flex container.</p>
+
+<div class="hidden">
+<pre class="brush: css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.wrapper &gt; div {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}
+</pre>
+</div>
+
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div class="box1"&gt;One&lt;/div&gt;
+ &lt;div class="box2"&gt;Two&lt;/div&gt;
+ &lt;div class="box3"&gt;Three&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">.wrapper {
+ display: flex;
+ align-items: flex-end;
+ min-height: 200px;
+}
+.box1 {
+ align-self: stretch;
+}
+.box2 {
+ align-self: flex-start;
+}
+</pre>
+
+<p>{{ EmbedLiveSample('Box_alignment', '300', '230') }}</p>
+
+<h3 id="Alignment_in_CSS_Grids">Alignment in CSS Grids</h3>
+
+<p>This second example uses a grid to create the same layout. This time we are using the box alignment properties as they apply to a grid layout. So we align to <code>start</code> and <code>end</code> rather than <code>flex-start</code> and <code>flex-end</code>. In the case of a grid layout, we are aligning the items inside their grid area. In this case that is a single grid cell, but it could be an area made up of several grid cells.</p>
+
+<div class="hidden">
+<pre class="brush: css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.wrapper &gt; div {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}
+</pre>
+</div>
+
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div class="box1"&gt;One&lt;/div&gt;
+ &lt;div class="box2"&gt;Two&lt;/div&gt;
+ &lt;div class="box3"&gt;Three&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(3,1fr);
+ align-items: end;
+ grid-auto-rows: 200px;
+}
+.box1 {
+ align-self: stretch;
+}
+.box2 {
+ align-self: start;
+}
+</pre>
+
+<p>{{ EmbedLiveSample('Alignment_in_CSS_Grids', '200', '310') }}</p>
+
+<h3 id="The_fr_unit_and_flex-basis">The <code>fr</code> unit and <code>flex-basis</code></h3>
+
+<p>We have already seen how the <code>fr</code> unit works to assign a proportion of available space in the grid container to our grid tracks. The <code>fr</code> unit, when combined with the {{cssxref("minmax", "minmax()")}} function can give us very similar behavior to the <code>flex</code> properties in flexbox while still enabling the creation of a layout in two dimensions.</p>
+
+<p>If we look back at the example where I demonstrated the difference between one and two-dimensional layouts, you can see there is a difference between the way of the two layouts work responsively. With the flex layout, if we drag our window wider and smaller, the flexbox does a nice job of adjusting the number of items in each row according to the available space. If we have a lot of space all five items can fit on one row. If we have a very narrow container we may only have space for one.</p>
+
+<p>In comparison, the grid version always has three column tracks. The tracks themselves will grow and shrink, but there are always three since we asked for three when defining our grid.</p>
+
+<h4 id="Auto-filling_grid_tracks">Auto-filling grid tracks</h4>
+
+<p>We can create a similar effect to flexbox, while still keeping the content arranged in strict rows and columns, by creating our track listing using repeat notation and the <code>auto-fill</code> and <code>auto-fit</code> properties.</p>
+
+<p>In this next example, I have used the <code>auto-fill</code> keyword in place of an integer in the repeat notation and set the track listing to 200 pixels. This means that grid will create as many 200 pixels column tracks as will fit in the container.</p>
+
+<div class="hidden">
+<pre class="brush: css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.wrapper &gt; div {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}
+</pre>
+</div>
+
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div&gt;One&lt;/div&gt;
+ &lt;div&gt;Two&lt;/div&gt;
+ &lt;div&gt;Three&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, 200px);
+}
+</pre>
+
+<p>{{ EmbedLiveSample('Auto-filling_grid_tracks', '500', '170') }}</p>
+
+<h3 id="A_flexible_number_of_tracks">A flexible number of tracks</h3>
+
+<p>This isn’t quite the same as flexbox. In the flexbox example, the items are larger than the 200 pixel basis before wrapping. We can achieve the same in grid by combining <code>auto-fill</code> and the {{cssxref("minmax", "minmax()")}} function. In this next example, I create auto filled tracks with <code>minmax</code>. I want my tracks to be a minimum of 200 pixels, so I set the maximum to be <code>1fr</code>. Once the browser has worked out how many times 200 pixels will fit into the container–also taking account of grid gaps–it will treat the <code>1fr</code> maximum as an instruction to share out the remaining space between the items.</p>
+
+<div class="hidden">
+<pre class="brush: css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.wrapper &gt; div {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}
+</pre>
+</div>
+
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div&gt;One&lt;/div&gt;
+ &lt;div&gt;Two&lt;/div&gt;
+ &lt;div&gt;Three&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
+}
+</pre>
+
+<p>{{ EmbedLiveSample('A_flexible_number_of_tracks', '500', '170') }}</p>
+
+<p>We now have the ability to create a grid with a flexible number of flexible tracks, but see items laid out on the grid aligned by rows and columns at the same time.</p>
+
+<h2 id="Grid_and_absolutely_positioned_elements">Grid and absolutely positioned elements</h2>
+
+<p>Grid interacts with absolutely positioned elements, which can be useful if you want to position an item inside a grid or grid area. The specification defines the behavior when a grid container is a containing block and a parent of the absolutely positioned item.</p>
+
+<h3 id="A_grid_container_as_containing_block">A grid container as containing block</h3>
+
+<p>To make the grid container a containing block you need to add the position property to the container with a value of relative, just as you would make a containing block for any other absolutely positioned items. Once you have done this, if you give a grid item <code>position: absolute</code> it will take as its containing block the grid container or, if the item also has a grid position, the area of the grid it is placed into.</p>
+
+<p>In the below example I have a wrapper containing four child items. Item three is absolutely positioned and also placed on the grid using line-based placement. The grid container has <code>position: relative</code> and so becomes the positioning context of this item.</p>
+
+<div class="hidden">
+<pre class="brush: css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.wrapper &gt; div {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}
+</pre>
+</div>
+
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div class="box1"&gt;One&lt;/div&gt;
+ &lt;div class="box2"&gt;Two&lt;/div&gt;
+ &lt;div class="box3"&gt;
+ This block is absolutely positioned. In this example the grid container is the containing block and so the absolute positioning offset values are calculated in from the outer edges of the area it has been placed into.
+ &lt;/div&gt;
+ &lt;div class="box4"&gt;Four&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(4,1fr);
+ grid-auto-rows: 200px;
+ grid-gap: 20px;
+ position: relative;
+}
+.box3 {
+ grid-column-start: 2;
+ grid-column-end: 4;
+ grid-row-start: 1;
+ grid-row-end: 3;
+ position: absolute;
+ top: 40px;
+ left: 40px;
+}
+</pre>
+
+<p>{{ EmbedLiveSample('A_grid_container_as_containing_block', '500', '330') }}</p>
+
+<p>You can see that the item is taking the area from grid row line 2 to 4, and starting after line 1. Then it is offset in that area using the top and left properties. However, it has been taken out of flow as is usually for absolutely positioned items and so the auto-placement rules now place items into the same space. The item also doesn’t cause the additional row to be created to span to row line 3.</p>
+
+<p>If we remove <code>position:</code> <code>absolute</code> from the rules for <code>.box3</code> you can see how it would display without the positioning.</p>
+
+<h3 id="A_grid_container_as_parent">A grid container as parent</h3>
+
+<p>If the absolutely positioned child has a grid container as a parent but that container does not create a new positioning context, then it is taken out of flow as in the previous example. The positioning context will be whatever element creates a positioning context as is common to other layout methods. In our case, if we remove <code>position:</code> <code>relative</code> from the wrapper above, positioning context is from the viewport, as shown in this image.</p>
+
+<p><img alt="Image of grid container as parent" src="https://mdn.mozillademos.org/files/14661/2_abspos_example.png" style="height: 408px; width: 1702px;"></p>
+
+<p>Once again the item no longer participates in the grid layout in terms of sizing or when other items are auto-placed.</p>
+
+<h3 id="With_a_grid_area_as_the_parent">With a grid area as the parent</h3>
+
+<p>If the absolutely positioned item is nested inside a grid area then you can create a positioning context on that area. In the below example we have our grid as before but this time I have nested an item inside <code>.box3</code> of the grid.</p>
+
+<p>I have given <code>.box3</code> position relative and then positioned the sub-item with the offset properties. In this case, the positioning context is the grid area.</p>
+
+<div class="hidden">
+<pre class="brush: css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.wrapper &gt; div {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}
+</pre>
+</div>
+
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div class="box1"&gt;One&lt;/div&gt;
+ &lt;div class="box2"&gt;Two&lt;/div&gt;
+ &lt;div class="box3"&gt;Three
+ &lt;div class="abspos"&gt;
+ This block is absolutely positioned. In this example the grid area is the containing block and so the absolute positioning offset values are calculated in from the outer edges of the grid area.
+ &lt;/div&gt;
+ &lt;/div&gt;
+ &lt;div class="box4"&gt;Four&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(4,1fr);
+ grid-auto-rows: 200px;
+ grid-gap: 20px;
+}
+.box3 {
+ grid-column-start: 2;
+ grid-column-end: 4;
+ grid-row-start: 1;
+ grid-row-end: 3;
+ position: relative;
+}
+.abspos {
+ position: absolute;
+ top: 40px;
+ left: 40px;
+ background-color: rgba(255,255,255,.5);
+ border: 1px solid rgba(0,0,0,0.5);
+ color: #000;
+ padding: 10px;
+}
+</pre>
+
+<p>{{ EmbedLiveSample('With_a_grid_area_as_the_parent', '500', '420') }}</p>
+
+<h2 id="Grid_and_display_contents">Grid and <code>display: contents</code></h2>
+
+<p>A final interaction with another layout specification that is worth noting is the interaction between CSS Grid Layout and <code>display: contents</code>. The <code>contents</code> value of the display property is a new value that is described in the <a href="https://drafts.csswg.org/css-display/#box-generation">Display specification</a> as follows:</p>
+
+<blockquote>
+<p>“The element itself does not generate any boxes, but its children and pseudo-elements still generate boxes as normal. For the purposes of box generation and layout, the element must be treated as if it had been replaced with its children and pseudo-elements in the document tree.”</p>
+</blockquote>
+
+<p>If you set an item to <code>display:</code> <code>contents</code> the box it would normally create disappears, and the boxes of the child elements appear as if they have risen up a level. This means that children of a grid item can become grid items. Sound odd? Here is a simple example. In the following markup, I have a grid and the first item on the grid is set to span all three column tracks. It contains three nested items. As these items are not direct children, they don’t become part of the grid layout and so display using regular block layout.</p>
+
+<div id="Display_Contents_Before">
+<div class="hidden">
+<pre class="brush: css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.box {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}
+.nested {
+ border: 2px solid #ffec99;
+ border-radius: 5px;
+ background-color: #fff9db;
+ padding: 1em;
+}
+</pre>
+</div>
+
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div class="box box1"&gt;
+ &lt;div class="nested"&gt;a&lt;/div&gt;
+ &lt;div class="nested"&gt;b&lt;/div&gt;
+ &lt;div class="nested"&gt;c&lt;/div&gt;
+ &lt;/div&gt;
+ &lt;div class="box box2"&gt;Two&lt;/div&gt;
+ &lt;div class="box box3"&gt;Three&lt;/div&gt;
+ &lt;div class="box box4"&gt;Four&lt;/div&gt;
+ &lt;div class="box box5"&gt;Five&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ grid-auto-rows: minmax(100px, auto);
+}
+.box1 {
+ grid-column-start: 1;
+ grid-column-end: 4;
+}
+
+</pre>
+
+<p>{{ EmbedLiveSample('Display_Contents_Before', '400', '420') }}</p>
+</div>
+
+<p>If I now add <code>display:</code> <code>contents</code> to the rules for <code>box1</code>, the box for that item vanishes and the sub-items now become grid items and lay themselves out using the auto-placement rules.</p>
+
+<div id="Display_Contents_After">
+<div class="hidden">
+<pre class="brush: css">* {box-sizing: border-box;}
+
+.wrapper {
+ border: 2px solid #f76707;
+ border-radius: 5px;
+ background-color: #fff4e6;
+}
+
+.box {
+ border: 2px solid #ffa94d;
+ border-radius: 5px;
+ background-color: #ffd8a8;
+ padding: 1em;
+ color: #d9480f;
+}
+.nested {
+ border: 2px solid #ffec99;
+ border-radius: 5px;
+ background-color: #fff9db;
+ padding: 1em;
+}
+</pre>
+</div>
+
+<pre class="brush: html">&lt;div class="wrapper"&gt;
+ &lt;div class="box box1"&gt;
+ &lt;div class="nested"&gt;a&lt;/div&gt;
+ &lt;div class="nested"&gt;b&lt;/div&gt;
+ &lt;div class="nested"&gt;c&lt;/div&gt;
+ &lt;/div&gt;
+ &lt;div class="box box2"&gt;Two&lt;/div&gt;
+ &lt;div class="box box3"&gt;Three&lt;/div&gt;
+ &lt;div class="box box4"&gt;Four&lt;/div&gt;
+ &lt;div class="box box5"&gt;Five&lt;/div&gt;
+&lt;/div&gt;
+</pre>
+
+<pre class="brush: css">.wrapper {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ grid-auto-rows: minmax(100px, auto);
+}
+.box1 {
+ grid-column-start: 1;
+ grid-column-end: 4;
+ display: contents;
+}
+</pre>
+
+<p>{{ EmbedLiveSample('Display_Contents_After', '400', '330') }}</p>
+</div>
+
+<p>This can be a way to get items nested into the grid to act as if they are part of the grid, and is a way around some of the issues that would be solved by subgrids once they are implemented. You can also use <code>display:</code> <code>contents</code> in a similar way with flexbox to enable nested items to become flex items.</p>
+
+<p>As you can see from this guide, CSS Grid Layout is just one part of your toolkit. Don’t be afraid to mix it with other methods of doing layout to get the different effects you need.</p>
+
+<h2 id="See_Also">See Also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Learn/CSS/CSS_layout/Flexbox">Flexbox Guides</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Columns">Multiple-column Layout Guides</a></li>
+</ul>
+
+<section class="Quick_links" id="Quick_Links">
+<ol>
+ <li><a href="/en-US/docs/Web/CSS"><strong>CSS</strong></a></li>
+ <li><a href="/en-US/docs/Web/CSS/Reference"><strong>CSS Reference</strong></a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout">CSS Grid Layout</a></li>
+ <li data-default-state="open"><a href="#"><strong>Guides</strong></a>
+ <ol>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout">Basics concepts of grid layout</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Relationship_of_Grid_Layout">Relationship to other layout methods</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Line-based_Placement_with_CSS_Grid">Line-based placement</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Grid_Template_Areas">Grid template areas</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Layout_using_Named_Grid_Lines">Layout using named grid lines</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Auto-placement_in_CSS_Grid_Layout">Auto-placement in grid layout</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Box_Alignment_in_CSS_Grid_Layout">Box alignment in grid layout</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid,_Logical_Values_and_Writing_Modes">Grids, logical values, and writing modes</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid_Layout_and_Accessibility">CSS Grid Layout and Accessibility</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/CSS_Grid_and_Progressive_Enhancement">CSS Grid Layout and Progressive Enhancement</a></li>
+ <li><a href="/en-US/docs/Web/CSS/CSS_Grid_Layout/Realizing_common_layouts_using_CSS_Grid_Layout">Realizing common layouts using grids</a></li>
+ </ol>
+ </li>
+ <li data-default-state="open"><a href="#"><strong>Properties</strong></a>
+ <ol>
+ <li><a href="/en-US/docs/Web/CSS/grid">grid</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-area">grid-area</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-auto-columns">grid-auto-columns</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-auto-flow">grid-auto-flow</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-auto-rows">grid-auto-rows</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column">grid-column</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column-end">grid-column-end</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column-gap">grid-column-gap</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-column-start">grid-column-start</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-gap">grid-gap</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row">grid-row</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row-end">grid-row-end</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row-gap">grid-row-gap</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-row-start">grid-row-start</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template">grid-template</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template-areas">grid-template-areas</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template-columns">grid-template-columns</a></li>
+ <li><a href="/en-US/docs/Web/CSS/grid-template-rows">grid-template-rows</a></li>
+ </ol>
+ </li>
+ <li data-default-state="open"><a href="#"><strong>Glossary</strong></a>
+ <ol>
+ <li><a href="/en-US/docs/Glossary/Grid">Grid</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_lines">Grid lines</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_tracks">Grid tracks</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_cell">Grid cell</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_areas">Grid areas</a></li>
+ <li><a href="/en-US/docs/Glossary/Gutters">Gutters</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_Axis">Grid Axis</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_rows">Grid row</a></li>
+ <li><a href="/en-US/docs/Glossary/Grid_column">Grid column</a></li>
+ </ol>
+ </li>
+</ol>
+</section>