I'm really confused. When looking for online resources and documentation, most of the documentation of these properties seem to reference Flex-box, not grid. And I don't know how applicable the documentation for the equivalent properties in Flex-box is to grid.
So, I've tried referencing https://css-tricks.com/snippets/css/complete-guide-grid/, which defines them as follows:
justify-items - Aligns the content inside a grid item along the row axis
justify-content - This property aligns the grid along the row axis
justify-self - Aligns the content inside a grid item along the row axis
But I still don't understand what the difference between them is. So, I have 3 questions I want to clarify.
justify-items
property in Flex-box the same as the justify-items
property in Grid? or are they different somehow? (In other words, can I reuse Flex-box documentation for Grid)Any clarification would be greatly appreciated.
Edit: Since everyone keeps giving me Flex-box resources, I am asking about css-grid, NOT flex-box.
Justify-content is flexbox specific and applied to a flex container. You declare how the flex items within that container will be aligned along the main axis. Justify items is applied to a container and has the below effects: In block-level layouts, it aligns the items inside their containing block on the inline axis.
justify-content — controls alignment of all items on the main axis. align-items — controls alignment of all items on the cross axis.
The CSS justify-self property sets the way a box is justified inside its alignment container along the appropriate axis.
1
As reiallenramos mentioned, "The justify-self and justify-items properties are not implemented in flexbox. This is due to the one-dimensional nature of flexbox, and that there may be multiple items along the axis, making it impossible to justify a single item. To align items along the main, inline axis in flexbox you use the justify-content property." - MDN
2-3
This screen shot from W3 does an excellent job of showing what they do and the differences between them.
For more information and example, I would suggest you check out:
And for some inspiration:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With