Template:Sticky header/doc
File:Edit-copy green.svg | Template:Strong for Template:Terminate sentence It may contain usage information, categories and other content that is not part of the original template page. |
Lua error in Module:TNT at line 159: Missing JsonConfig extension; Cannot load https://commons.wikimedia.org/wiki/Data:I18n/Uses TemplateStyles.tab.
This adds a floating, sticky header to a table in desktop view, but not on cell phones. It only works with sortable tables.
It has been tested, and works, in these browsers: Firefox, Edge, Chrome, Opera. Header borders are missing in Firefox. For more info see: Help:Table#Tables with sticky headers
It works with simple one-line headers, and with complex, multi-line, multi-row headers that use colspan and rowspan in the headers.
See list of articles transcluding {{sticky header}}
. See transclusion count.
Usage
- Note: See sandbox with examples.
{{sticky header}}
just above the table wikitext.
class=sticky-header
to the top line of the table wikitext along with class=sortable
. For example:
- <syntaxhighlight lang=wikitext>
</syntaxhighlight>
With sticky template
Name | Data columns are below | ||
---|---|---|---|
1 | 2 | 3 | |
Name1 | 1-1 | 2-1 | 3-1 |
Name2 | 1-2 | 2-2 | 3-2 |
Name3 | 1-3 | 2-3 | 3-3 |
Name4 | 1-4 | 2-4 | 3-4 |
Name5 | 1-5 | 2-5 | 3-5 |
Name6 | 1-6 | 2-6 | 3-6 |
Special cases
- Note: See sandbox with examples.
Sometimes a single-row sticky header is required due to subsection table header rows within the table. Note placement of class=sticky
below. Scroll down well into the table to see that the headers before subsections of the table do not stick. Those subsection headers should not stick since they change as you scroll down the table.
Wiki source excerpt: <syntaxhighlight lang=wikitext highlight=1,4>
</syntaxhighlight> Go down to a section farther down in the example sandbox for a more complex table with multi-row headers, and table subsections. A different solution was required. Problems and solutionsSee: Template talk:Sticky header. It works with {{static row numbers}}. But it does not work with this subtemplate: {{static row numbers table}} (go there to see what to replace it with). It breaks this subtemplate: {{static row numbers arrows}}. The separate sort row disappears. Use {{sort row}} instead.
|
---|