[css3-flexbox] do I like auto margins?

Every time auto margins are mentioned, Tab points at me and says he hates it by I like them, so we have to deal with them, but wouldn't be it great if they just dead! or something like that...

I want to set the record straight here. I never liked auto margins, I didn't come up with that either. I have no feelings to them now either. Let's just make a good spec.

Why do we have auto margins work at all?

When Tab has joined CSSWG and started working on flexbox, he really wanted flex margins and flex everything. That's where flex() function came from - to flex margins. There was a killer use case - to have flexible empty space between flexible controls, supposedly a common case where people have to use placeholders in XUL. Fantasai wanted that to work without placeholders too...

Old spec had auto margins working for alignment; Grid has auto margins too and it seems natural that auto margins work to align a box in a grid cell.

History aside... Let's not point at each other, let's find a real reason for auto margins to work or not, and I will be happy with either outcome.

Why have auto margins?

1) Integration with CSS box model seems more complete. All other box model settings have specific effect.
2) Some uses of flexbox are similar to existing CSS. In that situations it will be intuitive that margins work exactly as in flow, and surprising if they don't.
3) Consistency with Grid.
4) Safe alignment (vs. true center etc. with flex-align). If auto margins are dropped, we may have to add a few values to flex-align...
5) Finally, box model formulas with symmetry in 2 dimensions and all values actually work! "margin:auto" on a single child of flexbox will size it to content then center in two dimensions. Didn't you always want that to work?


Why not have auto margins?

1) Most of above reasons are not important primary use cases.
2) I haven't seen anybody actually use auto margins. Yet.
3) Shorter spec, less tests.

Have fun resolving this in F2F. Microsoft can live with them or without.

Alex

Received on Tuesday, 8 May 2012 20:27:36 UTC