Primer CSS Flexbox Grids
Primer CSS is a free open-source CSS framework that is built with the GitHub design system to provide support to the broad spectrum of Github websites. It creates the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by Object-Oriented CSS principles, functional CSS, and BEM architecture. It is a highly reusable model.
Flexbox grids are used to get responsive layouts. The flexbox grids are useful for keeping columns the same height, justifying content, and vertically aligning items. Flex utility classes are used on div containers and columns.
Primer CSS Flexbox Grids classes:
- col-*: It defines the number of columns up to 12.
- d-flex: This class is used to set a block that lays out its content using the flexbox model.
- d-inline-flex: This class is used to set an inline element that lays out its content using the flexbox model.
- flex-justify-start: This class is used to justify all items to the left.
- flex-justify-end: This class is used to justify all items to the right.
- flex-justify-center: This class is used to justify items to the center of the container.
- flex-justify-between: This class is used to distribute items evenly. The first item is on the start line, the last item is on the end line.
- flex-justify-around: This class is used to distribute items evenly with equal space around them.
- flex-items-start: This class is used to align items to the start of the cross axis.
- flex-items-end: This class is used to align items to the end of the cross axis.
- flex-items-center: This class is used to align items to the center of the cross axis.
- flex-items-baseline: This class is used to align items along their baselines.
- flex-items-stretch: This class is used to stretch items from the start of the cross-axis to the end of the cross-axis vertically.
Note: The above classes are used in combination for the desired result as per the application’s need.
<div class="o-container"> <div class="col-* d-flex"> ... </div> <div class="col-* flex-justify-center flex-md-items-start"> ... </div> </div>
Example: The following code demonstrates the Primer CSS flexbox grids by using flex utilities on containers and columns.