The curious case of equidistant boxes, a CSS fail
blog.directededge.com
blog.directededge.com
http://limpet.net/mbrubeck/projects/justify-block.html
View source to see the details. It's very slightly tricky because the last line of a "text-align:justify" element is not fully justified, so you need force it to wrap. In my test file I used a generated "spacer" element to do this. In practice you would probably hide this element by setting its height to zero or something.
One nice thing about this is how it continues to work even as you resize the container so the children don't fit on one row. (Resize your browser window to try it.)
As an addendum, in the non-contrived case (the one the widget actually uses) it also allows text to spread beyond the width of the image above it unless it's on the extreme edges; I haven't yet thought through if that'd be possible with this or using td spacers with a little extra finageling.
http://blog.directededge.com/wp-content/uploads/2010/04/reco...
Note the Coffee > Everything label.
Edit: Reason it wasn't working in IE 7 was because I didn't add a doctype and it dropped into quirks mode.
With images, I've managed this: http://dl.dropbox.com/u/363028/temporary/justify_images.html
Though it's giving me a 4px taller container for the images than is needed :\ (forgive me if I'm missing something obvious there) It works on Safari 4 w/o the widths or the height, too, all that's needed are justify, inline, and that spacer (nice catch, that).
edit: via browsershots: http://browsershots.org/http://dl.dropbox.com/u/363028/tempo...
looks pretty consistent, for the most part. Probably breaking on inline-divs where it's failing. (and Opera is the only top-aligning one...? maybe that's a user stylesheet issue.)
Of course, this gives you no guarantee that there wouldn't be two overlapping labels in adjacent products. To test for and prevent that, you would still be on the hook for some JS, but it would be much simpler than the JS that's already in place. Basically just some jQuery to step through the pairs of adjacent objects and check the overlap of the internal spans containing the text.
Anyone want to write a compatibility shim for IE?
edited to add:
Live example, now including liquid-width demo as well: http://xavvy.com/news.yc/html-distribute.html
perhaps the design can be thought out again, though. instead of getting the first flush with the left and last flush with the right, you could just create a bunch of blocks with centered content (think: floated list items in a list). there will be a little extra spacing on the left and right, but you can design it so that it's not too bothersome. i'm thinking
(_A_)_(___B___)_(__C__)_(_D_)
instead of (A_______B________C______D)
your point about CSS having not really solved this problem yet is a valid one, but solutions are in the works (namely, the flexible box model).Also, would it look good with multiple columns? I think items would have to be aligned vertically for it to look OK?
But styling via JavaScript because you couldn't do it in CSS? Yech. Especially if it's not some kind of UI component that needs JavaScript interaction like an accordion or drag handle or something.
I'm not sure what the author's point was exactly. There are tons of things that are easier to do with "classic" html or just plain hard to do with css alone. Even though we've been hearing ever since its invention that css is incredible, I'm still not convinced. It's certainly useful, but in so many ways limiting and annoying.
Which is different from CSS how exactly?
Text is small and most sane server configs are gziping it on top of that. We're literally talking about 500 bytes.
As for gzipping etc. it's the not the actual size that matters it's the latency + the fact that it's a new connection. TCP/IP connection takes a while and then (for larger files) you have to deal with slow start. This wouldn't be a huge deal if everyone supported pipelining, but they don't.
Can you cite?
Whether that's significant or not is a matter of opinion. Most estimates I've seen are 3-6%, but should be taken with a big grain of salt. For sites I've worked on I tend to see about 2-4% of users using Google Chrome as their browser, for comparison.
I realize this doesn't help much.
I was aware that most web stats packages use javascript to report stats - when we did the exercise of checking for disabled JS, that's where we looked.