responsive tables with axis-swap for mobile (and pseudo-headers instead of th)
| Entry’s title | 1st col | 2nd col | 3rd col | 4th col |
|---|---|---|---|---|
| Renault Twingo 2023 | X7868-9448-00928 | XAUZZ17449930020 | XAG-ZZ0440030029 | X-9289 4432 8820 |
| Ford Focus Tournier 1.0eco 5-Gang | @7868-9288-00998 | ZZ1782993WAU0000 | PSA-DL0018810089 | ZUR-428962328890 |
| Ferrari Enzo 612 | #7868-9288-00998 | WAUZZ17829930000 | VAG-ZZ0020030089 | L-9289 5232 8890 |
| Brabus GT950 | WAUZZ17829930000 | #7868-9288-00998 | L-9289 5232 8890 | VAG-ZZ0020030089 |
There are dozens of methods to display tabular content responsively, this one is relatively simple and based on plain html table markup. It solves the problem of scrolling away the column headers – without scripting.
The labels for mobile (single column) are created as :before pseudo element, the disadvantage here is: content is in the stylesheet, which screen readers do not like. But in the th the information is still present in the source, so this shouldn‘t be a problem.
In order not to require a new stylesheet build the very classes to edit the pseudo-contents are kept in the head section of the respective page. Like this one here:
@media all and (min-width: 20em) {
table td:nth-child(1):not(:empty):before {
content: " ";
}
table td:nth-child(2):not(:empty):before {
content: "1st col";
}
table td:nth-child(3):not(:empty):before {
content: "2nd col";
}
…
}
/* pseudo classes switched off */
@media all and (min-width: 48em) {
table td:before {
display: none;
}
}
<ul> and <li> what these examples should help illustrate.card for the surrounding container and .smaller for the entire list..mono for the entire list..larger for the entire list..card for the surrounding container and .smallest for the entire list.
<section class="row">
<div class="co-4 card">
<ul class="smallest">
<li>item</li>
</ul>
</div>
</section>
dl dt dd to the grid system, but nothing beyond that. Do not use this element (nor <ul> elements) to merely create indentation on a page. Although it works, this is a bad practice and obscures the meaning of description lists.dl ever make it into a full-width container (on the desktop end) – there is a character-per-line limit in place 75ch and an slightly increased line-height of 1.5, but less than the regular paragraphs here (1.75).dls, since the definition allows for more than one description for each term, which messes with the alignment a lot. So if we need a grid-like appearance, just use columns.Disclaimer: Everything here is free to use, but no responsibility is taken for any outcome. Questions & Suggestions: ak at alexkoch dot net (you‘re not a robot, I know). And I don‘t use cookies. Version history