CSS flexbox: The flex property in CSS is the combination of flex-grow, flex-shrink, and flex-basis property. It is used to set the length of flexible items. The flex property is much responsive and mobile friendly. It is easy to positioning child elements and the main container. The margin doesn’t collapse with the content margins. Order of any element can be easily changed without editing the HTML section. The flexbox was added to the CSS standards a few years ago to manage space distribution and element alignment. Basically it is one-dimensional layout syntax.
Vertical align to center: The flexbox property is used to set the content to vertical align. The text content can be aligned vertically by setting the following display properties:
align-items and justify-content are the important properties to absolutely center text horizontally and vertically. Horizontally centering is managed by the justify-content property and vertical centering by align-items property.
Example 1: This example set the text content vertically align to center.
Example 2: This example illustrates how to set left align text vertically in a flexbox using CSS.
- How to vertically and horizontally align flexbox to center ?
- How to Vertically Align Text Next to an Image using CSS ?
- How to align flexbox columns left and right using CSS ?
- How to align objects vertically when working with grids in CSS ?
- How to make an image center-aligned (vertically & horizontally) inside a bigger div using CSS?
- How to vertically center text with CSS?
- How to make flexbox children 100% height of their parent using CSS?
- How to set flexbox having unequal width of elements using CSS ?
- How to vertically flip a text canvas using Fabric.js ?
- Difference between align-content and align-items
- Advance CSS layout with flexbox
- Making a div vertically scrollable using CSS
- CSS | text-align Property
- CSS | text-align-last Property
- Differences between HTML <center> Tag and CSS "text-align: center;" Property
- How to align text in CSS where both columns are straight?
- Flexbox utilities in bootstrap with examples
- How to set space between the flexbox ?
- What are the differences between flex-basis and width in Flexbox ?
- How to place content under fixed flexbox navigation bar ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.