News for hackers. Stuff that matters.
Re:How to center a div in CSS by thr33 on Tuesday February 13, 2024 @05:01PM (#39363438)
justify/align and content/items have specific meanings and the 'intuitive' naming most people expect - horizontal, vertical - completely betrays the powerful elegance of the flex model.

justify always refers to the main axis of a box model element, and align refers to the cross axis. by default, flex-direction is set to row, so justify often means horizontal and align often means vertical.

until it doesn't of course. when we switch tbe flex direction from row to column which is a very handy trick for easy responsive on small devices, the main axis is now vertical and the cross axis is now horizontal.

Re:How to center a div in CSS by zerocrates on Tuesday February 13, 2024 @06:36PM (#39364391)
There's just always going to be confusion because both pairs are basically synonyms: justify and align; items and content (what's the content of a flex container? flex items).

I buy the value in having them be main-axis and cross-axis properties rather than horizontal/vertical by name, but I don't know that I buy the justify/align distinction to represent that as being meaningful or memorable.

Re:How to center a div in CSS by pests on Tuesday February 13, 2024 @07:56PM (#39364995)
Its similar with changing "left" and "right" to be "start" and "end" because we built in a lot of assumptions with LTR languages that don't apply to RTL.
Re:How to center a div in CSS by chihuahua on Tuesday February 13, 2024 @07:50PM (#39364950)
It's very easy to remember all this, if you can just memorize the acronym AMIJAMITCOE ("Ami-Jamit-Coe"): A monad is just a monoid in the category of endofunctors.
Re:How to center a div in CSS by RheingoldRiver on Wednesday February 14, 2024 @01:58AM (#39367250)
My mnemonic for justify vs align is to picture the "justification" options in a word processor. you can justify content to the side of the primary axis when it's written right-to-left. so, justify is main axis, and the one that's not justify (align) is the one that's not main axis (cross axis).

What I don't remember ever is does flex default to row or column; so I write a lot of unnecessary `flex-direction:row;` but if you are fine with always specifying a direction, the default doesnt really matter either.

Re:How to center a div in CSS by crazygringo on Wednesday February 14, 2024 @02:07PM (#39373789)
Which is even more confusing because that's not the terminology used in word processors.

Word processors have four modes of alignment -- left, center, right, and justified. Justified means stretching out to both edges.

There's no such thing as justifying content in a particular direction. And justifying something to the center is purely nonsensical.

Re:How to center a div in CSS by wruza on Tuesday February 13, 2024 @08:34PM (#39365285)
They could leave the elegance by calling it align-x and align-y and turn-right. Or make them independent of “direction”. Or allow both ways so people could use them in corresponding situations. Instead they chose to satisfy the most useless case of a pseudo-turnable container, which makes zero sense.