Template:Sticky table start/sandbox/styles.css: Difference between revisions
Appearance
Content deleted Content added
Jroberson108 (talk | contribs) Adjust print for collapsible button. |
Jroberson108 (talk | contribs) Shorten selectors. |
||
Line 131: | Line 131: | ||
overflow-y: visible; /* Default. */ |
overflow-y: visible; /* Default. */ |
||
} |
} |
||
.sticky-table-collapsible:not(.mw-collapsed) |
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-row1 > thead > tr:nth-child(1), |
||
.sticky-table-collapsible:not(.mw-collapsed) |
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-row1 > caption + tbody > tr:nth-child(1), |
||
.sticky-table-collapsible:not(.mw-collapsed) |
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-row1 > tbody:first-child > tr:nth-child(1), |
||
.sticky-table-collapsible:not(.mw-collapsed) |
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-row2 > thead > tr:nth-child(2), |
||
.sticky-table-collapsible:not(.mw-collapsed) |
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-row2 > caption + tbody > tr:nth-child(2), |
||
.sticky-table-collapsible:not(.mw-collapsed) |
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-row2 > tbody:first-child > tr:nth-child(2), |
||
.sticky-table-collapsible:not(.mw-collapsed) |
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-head > thead, |
||
.sticky-table-collapsible:not(.mw-collapsed) |
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-col1 > * > tr > :nth-child(1):not(.sticky-table-unsticky), |
||
.sticky-table-collapsible:not(.mw-collapsed) |
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-col2 > * > tr > :nth-child(2):not(.sticky-table-unsticky) { |
||
position: static; /* Default. */ |
position: static; /* Default. */ |
||
} |
} |
Revision as of 18:39, 30 July 2024
/**
* Make row N or thead element top sticky. Make column N left sticky.
*
* Div class:
* - sticky-table-scroll: contain table w/ auto scroll; height 75vh screen.
*
* Table classes:
* - sticky-table-head: top sticky thead; headers moved via sortable + JS.
* - sticky-table-row1: top sticky first row.
* - sticky-table-row2: top sticky second row.
* - sticky-table-row1: left sticky first column.
* - sticky-table-row2: left sticky second column.
*
* Cell classes:
* - sticky-table-unsticky: remove sticky to fix span issues.
*
* Notes:
* - Sortable moves to thead any header rows and (after sort) sorttop rows.
* - Sticky gadget (.mw-sticky-header) moves to thead any wikitable header rows.
*/
@media screen {
/**
* Div container with restricted height/width + scroll.
*/
.sticky-table-scroll {
margin-bottom: 1em; /* Moved from table. */
margin-top: 1em; /* Moved from table. */
max-height: 75vh;
max-width: max-content; /* Vertical scroll next to div. */
/* min-width: 300px; /* In case another element floats right. */
overflow-y: auto;
}
.sticky-table-scroll table {
margin-bottom: 0; /* Move to div. */
margin-top: 0; /* Move to div. */
}
.sticky-table-scroll table > caption {
text-align: left; /* Fix short centered caption hidden on wide table. */
}
/**
* Make top sticky.
*/
.sticky-table-scroll .sticky-table-row1 > thead > tr:nth-child(1),
.sticky-table-scroll .sticky-table-row1 > caption + tbody > tr:nth-child(1),
.sticky-table-scroll .sticky-table-row1 > tbody:first-child > tr:nth-child(1),
.sticky-table-scroll .sticky-table-row2 > thead > tr:nth-child(2),
.sticky-table-scroll .sticky-table-row2 > caption + tbody > tr:nth-child(2),
.sticky-table-scroll .sticky-table-row2 > tbody:first-child > tr:nth-child(2),
.sticky-table-scroll .sticky-table-head > thead {
position: sticky; /* Was "static". */
top: 0;
z-index: 10;
}
/**
* Make left sticky.
*/
.sticky-table-scroll .sticky-table-col1 > * > tr > :nth-child(1):not(.sticky-table-unsticky),
.sticky-table-scroll .sticky-table-col2 > * > tr > :nth-child(2):not(.sticky-table-unsticky) {
position: sticky; /* Was "static". */
left: 0;
z-index: 9;
}
/**
* Fix scrolling data shows through sticky's transparent background.
*/
.sticky-table-scroll table:not(.wikitable) {
background-color: white;
}
.sticky-table-scroll table > thead,
.sticky-table-scroll table > tbody,
.sticky-table-scroll table > tfoot,
.sticky-table-scroll table > * > tr,
.sticky-table-scroll table > * > tr > td,
.sticky-table-scroll :not(.wikitable) > * > tr > th {
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-table-scroll .wikitable {
border-collapse: separate; /* Was "collapse". */
border-spacing: 0;
border-width: 1px 0 0 1px;
}
.sticky-table-scroll .wikitable > * > tr > td,
.sticky-table-scroll .wikitable > * > tr > th {
border-width: 0 1px 1px 0;
}
/* Adjust {{static row numbers}} borders. */
.sticky-table-scroll .static-row-numbers.wikitable > * > tr::before {
border-right-width: 1px;
}
/* .sticky-table-scroll .static-row-numbers.wikitable > * > .sorttop:not(:has(~ .sorttop))::before, */
.sticky-table-scroll .static-row-numbers.wikitable > tbody > tr:last-child::before,
.sticky-table-scroll .static-row-numbers.wikitable > tfoot > tr:last-child::before {
border-bottom-width: 1px;
}
.sticky-table-scroll .static-row-numbers.wikitable > tbody > tr:not(.static-row-header)::before {
border-top-width: 0 !important;
border-left-width: 0 !important;
}
/**
* Modify collapsible's show/hide.
* - Show: expand table w/o scroll or sticky.
* - Hide: collapse table w/ scroll and sticky content. Accessible.
*/
/* Button. */
.sticky-table-collapsible .mw-collapsible-toggle {
float: none; /* Was "right". */
padding-left: 0; /* Was "0.2em". */
padding-right: 0; /* Was "0.2em". */
}
/* Collapsed displays "show" button. */
.sticky-table-collapsible.mw-collapsed .mw-collapsible-content {
display: block !important; /* Was "none". */
}
/* Expanded displays "hide" button. */
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-scroll {
max-height: none !important; /* Default. */
overflow-y: visible; /* Default. */
}
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-row1 > thead > tr:nth-child(1),
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-row1 > caption + tbody > tr:nth-child(1),
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-row1 > tbody:first-child > tr:nth-child(1),
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-row2 > thead > tr:nth-child(2),
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-row2 > caption + tbody > tr:nth-child(2),
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-row2 > tbody:first-child > tr:nth-child(2),
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-head > thead,
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-col1 > * > tr > :nth-child(1):not(.sticky-table-unsticky),
.sticky-table-collapsible:not(.mw-collapsed) .sticky-table-col2 > * > tr > :nth-child(2):not(.sticky-table-unsticky) {
position: static; /* Default. */
}
/**
* Fix Timeless. Wasn't sticky when on very wide tables.
*/
body.skin-timeless .sticky-table-scroll .overflowed,
body.skin-timeless .sticky-table-scroll .overflowed .content-table {
overflow: visible; /* Reset. */
}
body.skin-timeless .sticky-table-scroll .overflowed {
margin-top: 0; /* Was "1em". */
margin-bottom: 0; /* Was "1em". */
}
body.skin-timeless .sticky-table-scroll .scroll-right.overflowed .content-table-right {
box-shadow: none; /* Reset. */
border-left: none; /* Reset. */
}
body.skin-timeless .sticky-table-scroll .wikitable {
padding: 0;
}
/**
* Reset Sticky Table Headers gadget styles causing sticky issues if enabled.
*/
.sticky-table-scroll .jquery-tablesorter > thead,
.sticky-table-scroll .mw-sticky-header > thead {
top: 0 !important; /* Was value based on skin and max/min width. */
}
.sticky-table-scroll .jquery-tablesorter > tfoot,
.sticky-table-scroll .mw-sticky-header > tfoot {
position: static; /* Was "sticky". */
bottom: auto; /* Was "0". */
}
}
/**
* Fix skins width <=639px (mobile) not sticky. Override to make sticky.
*/
@media screen and (max-width: 639px) {
body.skin-minerva .sticky-table-scroll table,
body.skin-monobook .sticky-table-scroll table,
body.skin-vector-legacy .sticky-table-scroll table,
body.skin-vector-2022 .sticky-table-scroll table
{
display: table; /* Was "block". */
}
body.skin-minerva .sticky-table-scroll table > caption {
display: table-caption; /* Was "block". */
}
}
@media print {
/* In case set in template parameter. */
.sticky-table-scroll {
max-height: none !important; /* Default. */
max-width: none !important; /* Default. */
}
/* Collapsible button. */
.sticky-table-collapsible .mw-collapsible-toggle {
display: none;
}
}