align-content in block layout

Despite what you might read in some corners of the internet, it’s been possible to vertically centre an element inside a parent for a very long time now. The align-content property from the Box Alignment spec does the job, however browsers require that you make the parent element either a flex or a grid layout. […]


This content originally appeared on Rachel Andrew and was authored by rachelandrew

Despite what you might read in some corners of the internet, it’s been possible to vertically centre an element inside a parent for a very long time now. The align-content property from the Box Alignment spec does the job, however browsers require that you make the parent element either a flex or a grid layout. While the property was specified to work in block layout, no browser had implemented it, until now.

Chrome 122 implements align-content for block containers, and it’s being implemented in WebKit too. If you view the following CodePen in Chrome 122 (Canary at the time of writing) you’ll see that the text is vertically centred—no display: flex required.

See the Pen align-content in block layout (Chrome 122) by Rachel Andrew (@rachelandrew) on CodePen.


This content originally appeared on Rachel Andrew and was authored by rachelandrew


Print Share Comment Cite Upload Translate Updates
APA

rachelandrew | Sciencx (2023-12-19T09:22:22+00:00) align-content in block layout. Retrieved from https://www.scien.cx/2023/12/19/align-content-in-block-layout/

MLA
" » align-content in block layout." rachelandrew | Sciencx - Tuesday December 19, 2023, https://www.scien.cx/2023/12/19/align-content-in-block-layout/
HARVARD
rachelandrew | Sciencx Tuesday December 19, 2023 » align-content in block layout., viewed ,<https://www.scien.cx/2023/12/19/align-content-in-block-layout/>
VANCOUVER
rachelandrew | Sciencx - » align-content in block layout. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/12/19/align-content-in-block-layout/
CHICAGO
" » align-content in block layout." rachelandrew | Sciencx - Accessed . https://www.scien.cx/2023/12/19/align-content-in-block-layout/
IEEE
" » align-content in block layout." rachelandrew | Sciencx [Online]. Available: https://www.scien.cx/2023/12/19/align-content-in-block-layout/. [Accessed: ]
rf:citation
» align-content in block layout | rachelandrew | Sciencx | https://www.scien.cx/2023/12/19/align-content-in-block-layout/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.