Chris Coyier posted a nice, working solution to a real problem over at CSS-Tricks. Basically, CSS lets you style your website to look and work well on mobile devices by over-writing the styles of your full-size website. There are performance drawbacks to this approach, but for the most part it’s the best-of-all-possible-worlds solution.
One thorny problem, though, is over-riding the style of certain elements that use the width of the screen liberally by default. One such element is the venerable data table.
Coyier’s solution is great in that each table cell is labeled. However, doing this requires either writing CSS manually for every data table on the site (which is near-impossible for large sites) or having the same thing done with scripting on either the server or client side:
I propose a generalized solution that requires no scripting whatsoever. The drawback of this method, though, is that the cells are not individually labeled. The example is also more compact, but this aspect can be tweaked by marrying the two methods:
Thanks to Chris Coyier for posting a thoughtful working solution, and thereby motivating me to post about my approach after sitting on it (in production no less!) for almost a year.