Grids and Flexbox Cheat Sheet
Grids and Flexbox Cheat Sheet
Grid
123
selector{
grid
A grid will allow you organize the various elements on your page.
grid-template-rows: none
This feature allows you configure your elements so that they are organized similarly to rows on a table.
grid-template-columns: none
This feature allows you configure your elements but with this setting the elements are organized like
columns on a table.
grid-template-areas: none
This feature allows you configure the names of a grid and how they sit in relation to one another.
grid-auto-rows: auto
Default setting for all row sizes that have not been explicitly configured.
grid-auto-columns: auto
Default setting for all column sizes that have not been explicitly configured.
grid-auto-flow: row
column-gap: normal
row-gap: normal
Defines the line names, and maintains a constant size of column items. Can accept a range of different
measurement sizes.
Determines the default size for columns that have not been explicitly configured.
Determines the default size for rows that have not been explicitly configured.
This defines two cells named main and right, that have a sizing of 75% of the viewport height.
This defines two cells named footer and footer, that have a sizing of 20 root em (rem). This defines the
size in relation to the html font size.
Gap
Alignment
Defines the default space that is allot to each item on the grid
Defines the default space related to an item along the grid’s block axis
This feature allows you align items with the block and inline directions.
Justification
Defines browser allocation of space to content items in relation to cross axis and block axis
place-content: center | start
This feature allows you align items with the block and inline directions.
Positioning
This relates to how the items are placed automatically within the grid
This relates to the size for columns created without specific size specifications
This relates to the size for rows created without specific size specifications
This property determines the starting column position an item is placed on a grid.
This property determines the starting row position an item is placed on a grid.
This property determines the end row position an item is placed on a grid.
Determines how an item is positioned inside its aligned container in relation to the appropriate axis.
This setting lets one align and justify an item within a block.
Flexbox
selector{
Here the selector can refer to any of the following flex attributes
Attribute selector
Class Selector
ID Selector
Type Selectors
Universal Selectors
The display relates to how you want the selector to be shown. Setting display to flex makes the given
selector a flex box. Setting display to inline-flex makes the selector a flex box container while will be
inline.
It is possible to specify the direction your elements will follow. Traditionally text goes from left to right
which is flex’s default setting however it can be set from right to left or even top to bottom. The four
flex-direction are:
The standard layout is to plot the elements from left to right in a straight line. The wrap feature allows
you customize this to match the size of the window displaying the page.
wrap: Automatically wrap the items with as the window space gets smaller.
Nowrap: Default setting, items remain rigid and don’t respond to adjustments made to the window size.
This determines how the flex items are to be positioned on the page. Items can be aligned in a variety of
ways
Flex-start: Similar to standard writing, items start at the top left-hand corner and are positioned from
left to right
Space-between: first and last item are flush with the left and right wall respectively, every other item is
evenly spaced.
Space-evenly: each item is equidistant from each other and the boundary wall
This attribute enables the flex container to grow proportionally to the other containers present.
The sets the initial main size of an item. It can be overridden if other stylized elements are configured.
order:position in flex /* Set ascending by default */
The standard positioning of items is by source order, however this feature will enable you to configure
where the items appear on the page.
This determines where on the page the child items will be positioned. Similar to the main flex attributes,
start is to the left and end is to the right.