CSS Grids
Ce contenu n’est pas encore disponible dans votre langue.
OxyProps offers a wide range of grids utility classes to fit all your needs.
NB: In this documentation, when you see this notation :
--o-property-{1-5}
, this means that all values from 1 to 5 exist. So when you see--o-property-{1-5}
, you can use :
--o-property-1
--o-property-2
--o-property-3
--o-property-4
--o-property-5
Behaviour
link BehaviourOxyProps grid utility classes set the following properties :
In Oxygen Builder, and in Bricks except for Bricks Sections and Bricks Containers, it also sets :
Both in Oxygen and Bricks, the classes need to “fight” with the builder defaults that sets display: flex
on sections (Oxy & Brx), containers (Brx) and div (Oxy). In these situations, the framework has higher selector specificity to achieve the expected result.
Simple Grids
link Simple GridsSimple grids define a specific number of columns having the same width.
The CSS variables
link The CSS variablesThe grid-template-columns
CSS property defines the line names and track sizing functions of the grid columns. Source MDN
pattern:
--o-grid-columns-{1-12}
These properties are set to : repeat(X, minmax(0, 1fr))
where X is the number of columns.
Usage
link UsageUse these CSS Variables with the grid-template-columns
property:
Will define a 3 columns grid.
The Utility Classes
link The Utility Classespattern:
o-grid-{1-12}
These classes are automatically registered in Oxygen and Bricks to be available in autosuggestion.
Asymetrical Grids
link Asymetrical GridsAsymetrical grids define a 2 comumns grid with uneven widths.
The width ratio is defined by the 2 values. For example, in a o-grid-2-3
grid, the first column will use 2 fractions of the available space, and the second column will use 3 fractions of the available space.
The CSS variables
link The CSS variablespattern:
--o-grid-columns-{1-5}-{1-5}
These properties are set to : xfr yfr
where x and y are the 2 fractional values.
NB: properties will equal fractional values, like
--o-grid-columns-3-3
don’t exist in the OxyProps framework.
Usage
link UsageUse these CSS Variables with the grid-template-columns
property:
Will define a 2 columns grid, the second column being twice as wide as the first column.
The Utility Classes
link The Utility Classespattern:
o-grid-{1-5}-{1-5}
NB: utility classes will equal fractional values, like
--o-grid-2-2
don’t exist in the OxyProps framework.
Spans & Starts
link Spans & StartsSpans allow grid cells to span over multiple columns or rows.
Starts allow grid cells to start at a specific columns or rows.
Columns
link ColumnsColumns Spans
link Columns SpansThe grid-column-end
CSS property specifies a grid item’s end position within the grid column by contributing a line, a span, or nothing (automatic) to its grid placement, thereby specifying the block-end edge of its grid area. Source MDN
Pattern:
o-span-{1-12}
These classes set the grid-column-end
property.
Example:
This cell will span over 3 columns.
Columns Starts
link Columns StartsThe grid-column-start
CSS property specifies a grid item’s start position within the grid column by contributing a line, a span, or nothing (automatic) to its grid placement. This start position defines the block-start edge of the grid area. Source MDN
Pattern:
o-cstart-{1-12}
These classes set the grid-column-start
property.
Example:
This cell will start at column 5.
Rows
link RowsRows Spans
link Rows SpansPattern:
o-rspan-{1-12}
These classes set the grid-row-end
property.
Example:
This cell will span over 2 rows.
Rows Starts
link Rows StartsThe grid-column-start
CSS property specifies a grid item’s start position within the grid column by contributing a line, a span, or nothing (automatic) to its grid placement. This start position defines the block-start edge of the grid area. Source MDN
Pattern:
o-rstart-{1-12}
These classes set the grid-row-start
property.
Example:
This cell will start at row 3.
Order
link OrderThe order
CSS property sets the order to lay out an item in a flex or grid container. Items in a container are sorted by ascending order value and then by their source code order.
Note: Accessibility concerns - Using the order property will create a disconnect between the visual presentation of content and DOM order. This will adversely affect users experiencing low vision navigating with the aid of assistive technology such as a screen reader. If the visual (css) order is important, then screen reader users will not have access to the correct reading order. Source MDN
These classes set the order
property.
Responsive Grids
link Responsive GridsSimple and Asymetrical grids can be combined with breakpoints to achieve a responsive layout.
Use the pattern o-{breakpoint}-grid-{type of grid}
for this.
NB: You can chain multiple classes (1 per breakpoint) to achieve you responsive layout.
Breakpoints
link BreakpointsAvailable breakpoints are :
Grids at Breakpoints
link Grids at BreakpointsPattern:
o-{breakpoint}-grid{1-12}
Example:
This section will contain a grid with:
- 6 columns over XL breakpoint,
- 4 columns from LG to XL breakpoint,
- 3 columns from MD to LG breakpoint,
- 2 columns from SM to MD breakpoint,
- 1 columns below SM breakpoint,
Spans at Breakpoints
link Spans at BreakpointsPattern: o-{breakpoint}-span-{1-12}
Starts at Breakpoints
link Starts at BreakpointsPattern: o-{breakpoint}-cstart-{1-12}
RSpans at Breakpoints
link RSpans at BreakpointsPattern: o-{breakpoint}-rspan-{1-12}
RStarts at Breakpoints
link RStarts at BreakpointsPattern: o-{breakpoint}-rstart-{1-12}
Order at Breakpoints
link Order at BreakpointsPattern: o-{breakpoint}-{first-last}