Open nicoburns opened 1 year ago
But you can use place-content: center
for both axes. You will just need flex-wrap: wrap
to enable align-content
.
justify-items
just sets the default justify-self
of the children, and justify-self
doesn't make sense for items that flow along a line like in flex.
@dholbert answers the reasons behind this in detail here: https://stackoverflow.com/a/32569434/7983605
However, the css-align-3 specification says that justify-items
applies to all elements, which should need clarification here?
I think the correct behavior would be:
justify-items
Applies to: block-level boxes, absolutely-positioned boxes, and grid items
Spec links:
Motivation
Alignment with CSS Grid is wonderfully symmetrical: you can
align-items
in one axis andjustify-items
in the other and this does exactly the same thing. Sadly the same cannot be said for Flexbox:align-items
works nicely, butjustify-items
does nothing at all! I consider this undesirable for two reasons:-items
in one axis and-content
in the other, and it makes the naming scheme seem arbitrary to the point that I've observed that a lot of people seem to give up on learning the rules behind the alignment property naming entirely.place-
shorthand syntax can't be used. Which would be particularly nice in order to be able to do things likeplace-items: center
in order to center a single-child of a Flexbox node. Of course one can do this with Grid. But it would be nice if this capability was more universally avaialable.Proposal
It occurs to me that could be fixed. Specifically for the case when
justify-content
isstretch
(which is of course the default) we could enable thejustify-items
property to take effect.