Grid

24 Grids System。

Design concept#

100%
25%
25%
25%
25%
33.33%
33.33%
33.33%
50%
50%
66.66%
33.33%

In most business situations, Ant Design needs to solve a lot of information storage problems within the design area, so based on 12 Grids System, we divided the design area into 24 sections.

We name the divided area 'box'. We suggest four boxes for horizontal arrangement at most, one at least. Boxes are proportional to the entire screen as shown in the picture above. To ensure a high level of visual comfort, we customize the typography inside of the box based on the box unit.

Outline#

In the grid system, we define the frame outside the information area based on row and column, to ensure that every area can have stable arrangement.

Following is a brief look at how it works:

  • Establish a set of column in the horizontal space defined by row (abbreviated col)
  • Your content elements should be placed directly in the col, and only col should be placed directly in row
  • The column grid system is a value of 1-24 to represent its range spans. For example, three columns of equal width can be created by <div nz-col [nzSpan]="8" />.
  • If the sum of col spans in a row are more than 24, then the overflowing col as a whole will start a new line arrangement.

Our grid systems base on Flex layout to allow the elements within the parent to be aligned horizontally - left, center, right, wide arrangement, and decentralized arrangement. The Grid system also supports vertical alignment - top aligned, vertically centered, bottom-aligned. You can also define the order of elements by using order.

Layout uses a 24 grid layout to define the width of each "box", but does not rigidly adhere to the grid layout.

import { NzGridModule } from 'ng-zorro-antd/grid';

Examples

col-12
col-12
col-8
col-8
col-8
col-6
col-6
col-6
col-6

From the stack to the horizontal arrangement.

You can create a basic grid system by using a single set of nz-row and nz-col grid assembly, all of the columns (nz-col) must be placed in nz-row.

expand codeexpand code
      Loading...
    
Horizontal
col-6
col-6
col-6
col-6
Responsive
col-6
col-6
col-6
col-6
Vertical
col-6
col-6
col-6
col-6
col-6
col-6
col-6
col-6

You can use the nzGutter property of nzRow as grid spacing, we recommend set it to (16 + 8n) px. (n stands for natural number.)

You can set it to a object like { xs: 8, sm: 16, md: 24, lg: 32, xl: 32, xxl: 32 } for responsive design.

expand codeexpand code
      Loading...
    
col-8
col-8
col-6 col-offset-6
col-6 col-offset-6
col-12 col-offset-6

nzOffset can set the column to the right side. For example, using nzOffset = "4" can set the element shifted to the right four columns width.

expand codeexpand code
      Loading...
    
col-18 col-push-6
col-6 col-pull-18

By using nzPush and nzPull class you can easily change column order.

expand codeexpand code
      Loading...
    

sub-element align left

col-4
col-4
col-4
col-4

sub-element align center

col-4
col-4
col-4
col-4

sub-element align right

col-4
col-4
col-4
col-4

sub-element monospaced arrangement

col-4
col-4
col-4
col-4

sub-element align full

col-4
col-4
col-4
col-4

sub-element align evenly

col-4
col-4
col-4
col-4

Child elements depending on the value of the start, center, end, space-between, space-around, space-evenly, which are defined in its parent node layout mode.

expand codeexpand code
      Loading...
    

Align Top

col-4

col-4

col-4

col-4

Align Center

col-4

col-4

col-4

col-4

Align Bottom

col-4

col-4

col-4

col-4

Child elements vertically aligned.

expand codeexpand code
      Loading...
    
1 col-order-4
2 col-order-3
3 col-order-2
4 col-order-1

To change the element sort by nzOrder.

expand codeexpand code
      Loading...
    

Percentage columns

2 / 5
3 / 5

Fill rest

100px
Fill Rest

Raw flex style

1 1 200px
0 1 300px

nz-col provides nzFlex prop to support fill rest.

expand codeexpand code
      Loading...
    
Col
Col
Col

Referring to the Bootstrap [responsive design] (http://getbootstrap.com/css/#grid-media-queries), here preset five dimensions: xssmmdlgxl.

expand codeexpand code
      Loading...
    
Col
Col
Col

spanpullpushoffsetorder property can be embedded into nzXsnzSmnzMdnzLgnzXlnzXXl properties to use, where nzXs="6" is equivalent to [nzXs]="{ span: 6 }".

expand codeexpand code
      Loading...
    
Horizontal Gutter (px):
81624324048
Vertical Gutter (px):
81624324048
Column Count:
2346812
Column
Column
Column
Column
Column
Column
Column
Column

A simple playground for column count and gutter.

expand codeexpand code
      Loading...
    

API#

[nz-row]#

PropertyDescriptionTypeDefault
[nzAlign]the vertical alignment'top'|'middle'|'bottom'-
[nzGutter]spacing between grids, could be a number or a object like { xs: 8, sm: 16, md: 24}. or you can use array to make horizontal and vertical spacing work at the same time [horizontal, vertical]string|number|object|[number, number]|[object, object]0
[nzJustify]horizontal arrangement'start'|'end'|'center'|'space-around'|'space-between'-

[nz-col]#

PropertyDescriptionTypeDefault
[nzFlex]flex layout stylestring | number-
[nzOffset]the number of cells to offset Col from the leftnumber0
[nzOrder]raster ordernumber0
[nzPull]the number of cells that raster is moved to the leftnumber0
[nzPush]the number of cells that raster is moved to the rightnumber0
[nzSpan]raster number of cells to occupy, 0 corresponds to display: nonenumber-
[nzXs]<576px and also default setting, could be a span value or an object containing above propsnumber | object-
[nzSm]≥576px, could be a span value or an object containing above propsnumber | object-
[nzMd]≥768px, could be a span value or an object containing above propsnumber | object-
[nzLg]≥992px, could be a span value or an object containing above propsnumber | object-
[nzXl]≥1200px, could be a span value or an object containing above propsnumber | object-
[nzXXl]≥1600px, could be a span value or an object containing above propsnumber | object-

The breakpoints of responsive grid follow BootStrap 4 media queries rules(not including occasionally part).