Responsive table without wrapping container

.responsive makes a table full-bleed and scroll on mobile, without a need for a redundant wrapper (finally). Tables inside /css/breakout are responsive by default.


Demo table

Term Description
Link
Responsive design Approach to web design that aims to make web pages render well on a variety of devices and window or screen sizes from minimum to maximum display size to ensure usability and satisfaction. /wiki/Responsive_web_design

Living examples:

How it works
table.responsive,
.breakout > table:not(.does-not-exist),
.breakout-all > table:not(.does-not-exist) {
  /* Center horizontally */
  margin-left: 50%;
  transform: translateX(-50%);

  /* Let them full-bleed */
  width: max-content;
  min-width: auto;
  max-width: 100vw;
  padding-inline: 7.5%;

  /* Let them scroll */
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* Smooth scroll for iOS */

  th,
  td {
    padding-inline-start: 0;
  }
}

table:not(.does-not-exist) trick (inspired by postcss) is used here to increase specificity against selectors like &:is(table, .table)


Install

Via CDN
<link rel="stylesheet" href="
  https://cdn.jsdelivr.net/npm/@anyblades/blades@^0.28.0-alpha/assets/responsive-table.min.css
">
Prepackaged