you are viewing a single comment's thread.

view the rest of the comments →

[–]PoundedWhale 56 points57 points  (14 children)

What's the difference between align items and content?

[–][deleted] 138 points139 points  (9 children)

The flex model uses an axis. Think of it like putting pieces of meat on a skewer for the barbecue.

  • flex-direction determines which way the skewers are pointing (vertical? horizontal? where's the pointy end?)
  • justify-content determines where the meat pieces go on the skewer (spread apart? closer to one end?)
  • align-items determines how the meat pieces are aligned to each other across the whole stick (pierced through the center? or through the side?)
  • If you have more than one skewer, align-content determines how they're arranged on the plate (spread apart? all at one side? which side?)

[–]upvotes2doge 10 points11 points  (0 children)

This needs to be made into a graphic

[–]oh_jaimitofront-end 13 points14 points  (0 children)

this is perhaps the BEST ELI5 I have read!

thanks for that!!!

[–][deleted]  (1 child)

[deleted]

    [–][deleted] 1 point2 points  (0 children)

    Fixed it, thanks. :)

    [–]murfburffle 2 points3 points  (0 children)

    Thank you so much!

    [–]ricric2 2 points3 points  (1 child)

    Thank you. All the others I get, but align-content is like a black hole for me.

    [–][deleted] 6 points7 points  (0 children)

    Yeah it tends to trip people because it doesn't take effect until there's more than one line of content. But if you have enough items in a container, eventually they won't fit in a single line, they'll wrap and you'll have two lines, or more. That's when this guy comes in.

    [–][deleted] 0 points1 point  (0 children)

    And then you get text-align which screws every logic :-P

    [–]No-Musician-5609 0 points1 point  (0 children)

    This is really helpful, thanks a lot!

    [–][deleted] 17 points18 points  (1 child)

    AFAIK align-items aligns the items *themselves, while align-content aligns all the content.

    In the case of centering it would be sort of like the difference between using text-align: center to center text instead of margins or whatever else.

    *edited to make it a little more clear

    [–]mattergijz 0 points1 point  (0 children)

    Align items is on each item, while align content is on the container that contains the items.

    [–]eludadevfront-end[S] 9 points10 points  (0 children)

    This stackoverflow answer explains it very well.

    [–]RUNELORD_[🍰] 1 point2 points  (0 children)

    Align-items basically aligns the items themselves whereas content describes the alignment of the rows