[Brace yourselves, Responsive tables are coming]
DAVIDE L RIZZO @davidelrizzo
Melbourne based UX & Front-End 12+ years
SUNCORP GROUP: Personal, Business, Life Insurance & Banking Suncorp, AAMI, GIO, Bingle, Just Car, Shannons, Apia... and many more
[examples:https://www.aami.com.au/car-insurance.html]
(Understand that the horiz & vert alignment is what's important)
- Being responsive must be optional
- Vertical scrollbars is a valid option
- Collapse by rows if content is arranged horizontally
- Collapse by columns if content is arranged vertically
- Collapse to tabs or accordions
(
or display:table)-
Not as accessible as you might think
- No way to make a screen reader read verticaly down columns
and 'scope' dont really help at all
Collapsing responsively by 'columns' is harder than ruling 7 kingdoms IDEA: Generate a second responsive table and toggle on breakpoint CONS: Code duplication/bloat. Will duplicate unique IDs inside a table. IDEA: Rearrange the table with JS on breakpoint CONS: Requires JS & screen events, Must re-initialize contents on change IDEA: Switch from to display:flex CONS: Simply not possible to do vertical/horizontal & collapse row/column with the same markup
[Example: http://codepen.io/davidelrizzo/pen/eJwqzp?editors=1100]
[Example: http://codepen.io/davidelrizzo/pen/dGBxje?editors=1000]
[Example: http://codepen.io/davidelrizzo/pen/BjgXGg?editors=1100]
[Example: http://codepen.io/davidelrizzo/pen/GobVLe?editors=1100]
Use flex to align cell content in any way [Example: http://codepen.io/davidelrizzo/pen/PZMYWw?editors=0100] Easily add column margins by offsetting cell widths [Example: http://codepen.io/davidelrizzo/pen/LGwPeq] Zebra stripe the table.. ok you can't do this in pure CSS :( [Example: http://codepen.io/davidelrizzo/pen/BjXBrz?editors=0110] Emulate column spans with manual cell width
[Example: http://codepen.io/davidelrizzo/pen/gPVbYe?editors=1100] So flexy.. use it with any type of markup [Example: http://codepen.io/davidelrizzo/pen/VeoeqB?editors=1000] Only IE9 and below does not support flex. These old browsers will simply see the mobile version (graceful degradation FTW) |
---|