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

Pubblicato il: 31 ottobre 2021
sul canale di: 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...  


In questa pagina del sito puoi guardare il video online CSS Flexbox "justify-content: center" Explained - Beginner Tutorial della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Front End Beginners 31 ottobre 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 1,461 volte e gli è piaciuto 16 spettatori. Buona visione!