The Ashes
CSS 3 Flexible Box Model
Alex Russell has been having a really interesting discussion with some standards folks about what is wrong on the Web right now, and it narrowed down to discuss CSS variables as a case study (it aint perfect, but get DRY and ship it!)
Alex tells it how it is, but people forget that he does this as he is passionate about the Web, and that he does also give credit and positive outlook IF it is due!
His latest post shows this as he talked about CSS 3 progress and specifically the flexible box model that Mozilla and WebKit have had forevaaaaaah:
David Baron (of Mozilla fame) is editing a long-overdue but totally awesome Flexible Box spec, aka: “hbox and vbox”. Both Gecko and WebKit-derived browsers (read: everything that’s not IE) supports hbox and vbox today, but using it can be a bit tedious. Should you be working on an app that can ignore IE (say, for a mobile phone), this should help make box layouts a bit easier to get started with:
CSS:
/* hbox and vbox classes */ .hbox { display: -webkit-box; -webkit-box-orient: horizontal; -webkit-box-align: stretch; display: -moz-box; -moz-box-orient: horizontal; -moz-box-align: stretch; display: box; box-orient: horizontal; box-align: stretch; } .hbox> * { -webkit-box-flex: 0; -moz-box-flex: 0; box-flex: 0; display: block; } .vbox { display: -webkit-box; -webkit-box-orient: vertical; -webkit-box-align: stretch; display: -moz-box; -moz-box-orient: vertical; -moz-box-align: stretch; display: box; box-orient: vertical; box-align: stretch; } .vbox> * { -webkit-box-flex: 0; -moz-box-flex: 0; box-flex: 0; display: block; } .spacer { -webkit-box-flex: 1; -moz-box-flex: 1; box-flex: 1; } .reverse { -webkit-box-direction: reverse; -moz-box-direction: reverse; box-direction: reverse; } .boxFlex0 { -webkit-box-flex: 0; -moz-box-flex: 0; box-flex: 0; } .boxFlex1, .boxFlex { -webkit-box-flex: 1; -moz-box-flex: 1; box-flex: 1; } .boxFlex2 { -webkit-box-flex: 2; -moz-box-flex: 2; box-flex: 2; } .boxGroup1 { -webkit-box-flex-group: 1; -moz-box-flex-group: 1; box-flex-group: 1; } .boxGroup2 { -webkit-box-flex-group: 2; -moz-box-flex-group: 2; box-flex-group: 2; } .start { -webkit-box-pack: start; -moz-box-pack: start; box-pack: start; } .end { -webkit-box-pack: end; -moz-box-pack: end; box-pack: end; } .center { -webkit-box-pack: center; -moz-box-pack: center; box-pack: center; }
With this core baseline CSS you can then do great things such as easily vertically align (duh!)
and smart grouping:
The mighty Erik Arvidsson also reminds us of the CSS3 attr() support (already in Firefox, coming in WebKit too) that would enable us to wire up <div class=vbox flex=2>…</div>
.
Although you may be thinking “this is great, but freaking IE means that I don’t care about it.” True. It would be awesome if someone took a shim that could grok this CSS (we built a CSS parser for Thunderhead) and make it work in IE etc. But until that day, or the day that IE implements it (heh) what can you do?
Write iPhone or Palm webOS or Android WebKit apps? You can use it right friggin now!
No Comments