Flexbox CSS justify-content:space-*
Flexbox CSS justify-content:space-*
Flexbox layout and its properties are a set of properties which helps to align flex-items in a container. As we have discussed in detail in our previous articlesi) flexbox is a set of properties
ii) it helps to align grid elements in a container in may ways
iii) it also helps to realign the way it is arranged in a mobile or responsive screen without writing too much of code.
Justify-content
Justify-content is the property provided by flexbox concept which works like text-align property.Justify -around takes up the following values
justify-content: center | flex-start | flex-end | space-around | space-between | space-evenly
justify-content: space-*
justify-content: space-* helps us to align flex-items horizontally between the flex-container. In other words, it deals with the horizontal alignment within the containerjustify-content: space-around
space-around helps us to align items in such a way that items have equal space around them.The space between the items and the flex-container will be 1x, whereas space-between any two flex-items will be 2x.
Example
![CSS3 Flexbox CSS3 Flexbox](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHwxb9p3Cre0N4xsx0uqs_VhgRRD1yqTbR3h-kbsxZjr8YRT-61Xd2IaPtBKdFjzbAQ1hjEH5Jxjhx8fcbu_Vd25F-kDKBx5uXVVB2UFmQNQ51lvXD8wjQd18QdRRG3s8EMSjhzvY4lbct/s640/space-around.jpg)
Example with number of flex-items changed
![CSS3 Flexbox CSS3 Flexbox](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiweqlHgVRuF4b00xYbchHEvWVuen0XbYDFX0gcqJ4k6ja7l_i18hI2fjYqeYsAHMqie5GcbNJsr1yBxF6Z4rMC1o_9-HhFR6WAU-11f8aSbRxsCrDUxDb0VMpdqxtqvVWd04vzRSv_ADoi/s640/space-around-two.jpg)
justify-content: space-evenly
space-evenly helps us to align items in such a way that items have even space between them. The flex-items will have 1x space between any two flex-items and the flex-items and flex-container edges.![CSS3 Flexbox CSS3 Flexbox](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfEQo1kY5ebtRyBngdKzGidhnnuO5WX7qTNtn9CKh_I5l7RfQS4d9WHR4PoygqwhPCqvFWl8asWBYDf26znJBdzBmTJJXgPBXQpSnw3yA1Tyhmd3TG4Lhlc2reY7Ba0iBwKXZ4bhgUArhv/s640/space-evenly.jpg)
Another example showing justify-content:space-evenly
![CSS3 Flexbox CSS3 Flexbox](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY6Lm7Px9L-PkT38UnUizOsw2i-PzNeuus8qscdU6rqch1AWr4LGWIC1nodcaEBTuUzQ-GWkriYcugy_ibZQksMktPGakqCukf15EwPD32LHJovvyLsiULhyphenhyphen-_beSdNTzHpw4FyR05xQbO/s640/space-evenly-two.jpg)
Do you know
Recently, space-evenly has been made support and compatible with all modern browsers.
justify-content:space-between
space-between aligns the flex-items within the flex-container in such a way that space is allotted in between flex-items and not between the edges of the flex-container and the flex-items in the edges. The items in the edges move towards the edges in the left and right side respectively making space in between the flex items.Example for justify-content:space-between
![CSS3 Flexbox CSS3 Flexbox](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAZncoYR5cYERe-RMe4bxj1pu9KHb-hhnPzlCLrorZ_sds3J0zzIbTpMr6aRg2xJnTeAo_ixOpWdS9K3V_ztAMTxu4OAixMZvTiLpaSNlwFYSEuYv5CzUHFllYS4-36IOUxWvC62EjVkZa/s640/space-between.jpg)
Flex box also provides way to order the flex-items by giving a numeric value thereby aligning elements in responsive using flexbox very easy.
________________
Feel free to ask your doubts and share your feedback
Follow our FB page @CreativeTechnocrayts
Subscribe to Creative Technocrayts and be a part of growing community.
Comments
Post a Comment