CSS Flexbox "justify-content: center" Explained - Beginner Tutorial

Publié le: 31 octobre 2021
sur la chaîne: Front End Beginners
1,461
16

In this tutorial, we look at "justify-content: center" in CSS Flexbox.

The "justify-content" property aligns items along the "main axis", which always runs along the same plane as the "flex-direction" of the parent container—either horizontally or vertically, based upon "flex-direction: row" or "flex-direction: column".

"justify-content: center" takes any free space inside the parent flex container, divides it in half, and distributes it equally on either side of the child flex items, forcing them together in the center of the container. Note that this alignment works only along the main axis—any free space on the cross axis is ignored.

"justify-content: center" works with a single flex item, or with multiple flex items. As long as there is free space on the main axis, items will be centrally aligned.

We'll look at how this works in both the row and column directions, and how the cross axis is ignored—cross axis alignment is controlled by the "align-items" property, which is a topic for another video.

I hope you found this video helpful. If you have any questions, please leave them in the comments below and I'll do my best to answer as soon as possible.

TIMESTAMPS:

00:00 Introduction
00:25 Default positioning—"justify-content: flex-start"
01:42 How "justify-content: center" works
02:40 Working with multiple flex items
03:41 "justify-content" and the cross axis
05:36 "justify-content: center" and the "column" direction
06:55 Summary

WATCH NEXT:
• CSS Flexbox "justify-content: space-between" Explained -    • CSS Flexbox "justify-content: space-betwee...  
• CSS Flex Direction (flex-direction) Explained -    • CSS Flex Direction (flex-direction) Explai...  
• How to Perfectly Center and Element Using CSS Flexbox -    • How to Perfectly Center an Element Using C...  


Sur cette page du site, vous pouvez voir la vidéo en ligne CSS Flexbox "justify-content: center" Explained - Beginner Tutorial durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Front End Beginners 31 octobre 2021, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 1,461 fois et il a aimé 16 téléspectateurs. Bon visionnage!