StickyTableHeadersFix.css
From YGOCounter
/**
* Makes table headers sticky on small screens for Template:Sticky header * and MediaWiki:Gadget-StickyTableHeaders.css. * * See documentation: * {@link https://en.wikipedia.org/wiki/User:Jroberson108/StickyTableHeadersFix} */
/**
* Apply Template:Sticky header/styles.css to smaller screens. */
@media screen and (max-width: 639px) {
/**
* Make top sticky.
*/
.sticky-header > thead > tr:first-child,
.sticky-header > caption + tbody > tr:first-child,
.sticky-header > tbody:first-child > tr:first-child,
.sticky-header-multi > thead {
position: sticky; /* Was "static". */
top: 0;
z-index: 10;
}
/* Timeless overflowed tables not sticky. */
body.skin-timeless .content-table-wrapper.overflowed .sticky-header > thead > tr:first-child,
body.skin-timeless .content-table-wrapper.overflowed .sticky-header > caption + tbody > tr:first-child,
body.skin-timeless .content-table-wrapper.overflowed .sticky-header > tbody:first-child > tr:first-child,
body.skin-timeless .content-table-wrapper.overflowed .sticky-header-multi > thead {
position: static; /* Reset to prior. */
}
/**
* Fix scrolling data shows through sticky's transparent background.
*/
/* Plain table headers. */
.sticky-header:not(.wikitable),
.sticky-header-multi:not(.wikitable) {
background-color: var(--color-inverted, #fff);
}
/* Plain table headers. */
.sticky-header:not(.wikitable) > *, /* For thead, tbody. */
.sticky-header:not(.wikitable) > thead > tr:first-child,
.sticky-header:not(.wikitable) > caption + tbody > tr:first-child,
.sticky-header:not(.wikitable) > tbody:first-child > tr:first-child,
.sticky-header-multi:not(.wikitable) > thead,
/* Wikitable and plain table .sorttop rows after sort. */
.sticky-header-multi > thead {
background-color: inherit;
}
/** * Fix missing borders due to sticky position and wikitable collapsed borders. * https://bugs.webkit.org/show_bug.cgi?id=128486 * * Skip rare plain table separated borders, which sometimes shows scrolling * data through sticky's 2px "border-spacing". * * Skip very rare Timeless plain table ".mw-datatable" collapsed boarders. */ .sticky-header.wikitable, .sticky-header-multi.wikitable { border-collapse: separate; /* Was "collapse". */ border-spacing: 0; border-width: 0 1px 1px 0; } .sticky-header.wikitable td, .sticky-header.wikitable th, .sticky-header-multi.wikitable td, .sticky-header-multi.wikitable th { border-width: 1px 0 0 1px; } body.skin-timeless .content-table-wrapper:not(.overflowed) .sticky-header.wikitable, body.skin-timeless .content-table-wrapper:not(.overflowed) .sticky-header-multi.wikitable { border-bottom-width: 0.2em; padding: 0; } /* Adjust borders. */ .sticky-header.static-row-numbers.wikitable tr::before, .sticky-header-multi.static-row-numbers.wikitable tr::before { border-left-width: 1px; } .sticky-header.static-row-numbers.wikitable > thead > tr:first-child::before, .sticky-header.static-row-numbers.wikitable > caption + tbody > tr:first-child::before, .sticky-header.static-row-numbers.wikitable > tbody:first-child > tr:first-child::before, .sticky-header-multi.static-row-numbers.wikitable > thead > tr:first-child::before, .sticky-header-multi.static-row-numbers.wikitable > caption + tbody > tr:first-child::before, .sticky-header-multi.static-row-numbers.wikitable > tbody:first-child > tr:first-child::before, /* Sortbotton #1: all. When supported, consolidate #1-2 to tr:nth-child(1 of .sortbottom)::before */ .sticky-header.static-row-numbers.wikitable .sortbottom::before, .sticky-header-multi.static-row-numbers.wikitable .sortbottom::before { border-top-width: 1px; } /* Sortbottom #2: all minus 1st. */ .sticky-header.static-row-numbers.wikitable .sortbottom ~ .sortbottom::before, .sticky-header-multi.static-row-numbers.wikitable .sortbottom ~ .sortbottom::before { border-top-width: 0; } /* After sort, "tbody:first-of-type" targets "tbody>tr:first-child". */ .sticky-header.static-row-numbers.wikitable > tbody:first-of-type > tr:not(.static-row-header)::before, .sticky-header-multi.static-row-numbers.wikitable > tbody:first-of-type > tr:not(.static-row-header)::before { border-bottom-width: 0; border-right-width: 0; } /* Timeless overflowed tables not sticky. */ body.skin-timeless .content-table-wrapper.overflowed .sticky-header.wikitable, body.skin-timeless .content-table-wrapper.overflowed .sticky-header-multi.wikitable { border-collapse: collapse; /* Reset to prior. */ border-width: 1px; /* Reset to prior. */ }
}
/**
* For small screens, override global CSS so sticky tables works. * * Issues on all targeted skins <=639px wide: * - Windows and Android: when sticky table wider than main content area, table * overflowed and its horizontal scroll replaced with page-level, which * messes up page layout. * - Android (some): zoom out for sticky to work causing readability issues. * - iPhone: no known issues. */
@media screen and (max-width: 639px) {
body:not(.skin-timeless) .sticky-header,
body:not(.skin-timeless) .sticky-header-multi,
body:not(.skin-timeless) .jquery-tablesorter,
body:not(.skin-timeless) .mw-sticky-header {
display: table; /* Was "block". */
}
body.skin-minerva .sticky-header > caption,
body.skin-minerva .sticky-header-multi > caption,
body.skin-minerva .jquery-tablesorter > caption,
body.skin-minerva .mw-sticky-header > caption {
display: table-caption; /* Was "block". */
}
}