CSS Grid

Introduction

A grid is a set of intersectiong horizontal and vertical lines defining columns and row, and elements can be placed onto this grid within the column and row lines. Together with flxbox, grid is a powerful way to create an intricate CSS layout.

Features:


Grid Container

display: grid
display: inline-grid

An element is made into a grid container by display: grid or inline-grid declaration. All of its direct children become the grid items.

The default grid is to arrange the grid items vertically (1 column, multiple rows) just like in an unstyled list.

<!-- HTML -->
<div class="gridDefault">
    <div>Item 1</div>
    <div>Item 2</div>
    <div>Item 3</div>
    <div>Item 4</div>
    <div>Item 5</div>
</div>
/* CSS */
.gridDefault {
    display: grid;
    border: 4px solid plum;
}

.gridDefault div {
    border: 4px solid peachpuff;
}
Result
Item 1
Item 2
Item 3
Item 4
Item 5

Grid Tracks


Resources

Tools