I've tried to render a responsive table layout so that it shows a line of 12 columns on a desktop per each record of a table, 3 lines of 4 columns on a tablet and 6 of 2 cols on a smartphone.
What I've already done is to define a CSS3 with media queries and a demo html table
The issue is that - with the current implementation - the headers are always on top while I'd like to show them together with the cell values for small width views (smartphone/tablet), but I've no idea how to achieve this without hard-coding the headers in the CSS3, but in a parametric way.
You could also use
flexbox
and do a column based structure.Updated fiddle
Stack snippet
I think now I've found how to proceed.
I've to define the generic CSS classes for the desktop headers in the
th
tags and put the attributedisplay: none;
for such classes in the preliminary media queries for smartphones and tablets.Viceversa for the inline headers to be shown only on smaller size views.
I guess it should be the standard approach but I'm open to different ideas and suggestions. Anyway - as a side note - this kind of responsive table doesn't still look a practical approach to me: too many things could be designed in a different manner for mobile screens, not only headers and columns, but maybe also the number of records per page, the number of pages, etc... I guess I'd better off creating distinct mobile and desktop channels with completely different html pages