How does the justifyContent flexBox property work?

JustifyContent property aligns the flexible container’s items when the items do not use all available space on the main axis. By default, the main axis is vertical in the case of React native. This means justifyContent property aligns child elements of flex parent vertically in React native. We can use this property to layout elements in a flex container. JustifyContent supports the following values: flex-start|flex-end|centre|space-between|space-around|initial|inherit; It also applies some control over the alignment of items when they overflow the line. Let me explain JustifyContent’s values: 

  1. flex-start: this is the default value for justifyContent. It means that flex items will start from the top and be evenly distributed vertically. 
  2. Flex-end: this is just the opposite behavior of flex-start. Elements start rendering from the bottom 
  3. Center: Items will be placed in the middle 
  4. Space-between: elements are evenly distributed along the main axis (vertical axis) 
  5. Space-around: flex items will be evenly distributed with equal space around them 

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *