Template:Sticky header/styles.css

/** * Make first row or thead element top sticky. * * Table classes: * - sticky-header (first row) * - sticky-header-multi (thead; headers moved via sortab…

/**
 * Make first row or thead element top sticky.
 *
 * Table classes:
 * - sticky-header (first row)
 * - sticky-header-multi (thead; headers moved via sortable + JavaScript)
 *
 * Tested:
 * - Windows 10: (all skins) Chrome, Firefox, Edge.
 * - Android Galaxy S21 (Minerva): Chrome, Firefox.
 * - iPhone SE 2020 (Minerva): Chrome, Edge, Firefox, Opera, Safari.
 * - Wikipedia Android app.
 * - Print: Not styled.
 * - No JavaScript.
 *
 * 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 {
  /**
   * 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;
  }

  /**
   * Fix scrolling data shows through sticky's transparent background.
   */
  .sticky-header:not(.wikitable),
  .sticky-header-multi:not(.wikitable),
  body.skin-minerva .sticky-header-multi.wikitable { /* .wikitable .sorttop */
    background-color: white;
  }
  .sticky-header-multi > thead, /* .wikitable .sorttop & plain table */
  .sticky-header:not(.wikitable) > thead,
  .sticky-header:not(.wikitable) > tbody,
  .sticky-header:not(.wikitable) > thead > tr,
  .sticky-header:not(.wikitable) > tbody > tr { 
    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 .sticky-header.wikitable,
  body.skin-timeless .sticky-header-multi.wikitable {
    border-bottom-width: 0.2em;
    padding: 0;
  }
  /* Adjust {{static row numbers}} 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;
  }
  .sticky-header.static-row-numbers.wikitable > tbody > tr:not(.static-row-header)::before,
  .sticky-header-multi.static-row-numbers.wikitable > tbody > tr:not(.static-row-header)::before {
    border-bottom-width: 0;
    border-right-width: 0;
  }
}

/**
 * Adjust to other sticky elements.
 */
@media screen and (min-width: 1000px) {
  /* Vector (2022) width >=1000px: Below sticky header bar. */
  body.vector-sticky-header-visible .sticky-header > thead > tr:first-child,
  body.vector-sticky-header-visible .sticky-header > caption + tbody > tr:first-child,
  body.vector-sticky-header-visible .sticky-header > tbody:first-child > tr:first-child,
  body.vector-sticky-header-visible .sticky-header-multi > thead {
    top: 3.125rem;
  }
}
@media screen and (min-width: 851px) {
  /* Timeless width >=851px: Below sticky header bar. */
  body.skin-timeless .sticky-header > thead > tr:first-child,
  body.skin-timeless .sticky-header > caption + tbody > tr:first-child,
  body.skin-timeless .sticky-header > tbody:first-child > tr:first-child,
  body.skin-timeless .sticky-header-multi > thead {
    top: 3.51em;
  }
}

/**
 * Monobook width <=550px not sticky. Reset to avoid potential issues.
 *
 * Reason, can't override style:
 * - body.skin--responsive .monobook-body {overflow: auto;}
 */
@media screen and (max-width: 550px) {
  body.skin-monobook .sticky-header > thead > tr:first-child,
  body.skin-monobook .sticky-header > caption + tbody > tr:first-child,
  body.skin-monobook .sticky-header > tbody:first-child > tr:first-child,
  body.skin-monobook .sticky-header-multi > thead {
    position: static;
  }
  body.skin-monobook .sticky-header.wikitable,
  body.skin-monobook .sticky-header-multi.wikitable {
    border-collapse: collapse;
  }
}

/**
 * Minerva width <=720px (mobile) not sticky. Override to make sticky.
 *
 * Android issue: wide table horizontal scroll lost, wider page,
 * zoom out for sticky headers, unreadable when sticky.
 *
 * iPhone issue: none.
 */
@media screen and (max-width: 720px) {
  body.skin-minerva .sticky-header,
  body.skin-minerva .sticky-header-multi {
    display: table; /* Was "block". */
  }
  body.skin-minerva .sticky-header > caption,
  body.skin-minerva .sticky-header-multi > caption {
    display: table-caption; /* Was "block". */
  }
}

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.