User:Timeshifter/Sandbox33

From WikiProjectMed
Jump to navigation Jump to search

This is no longer necessary. There is now a better solution. See:

See also:

Fixed, automatic row numbering in a sortable table

/* Row numbering. */
table.rownumber {
	counter-reset: tablerownumber;
}
table.rownumber td.rownumber-value:before {
	content: counter(tablerownumber);
	counter-increment: tablerownumber;
}

See http://www.w3.org/TR/CSS21/generate.html#counters

  • Whenever a table with class rownumber is encountered, the counter is reset.
  • Whenever a table cell with class rownumber-value is encountered, a generated content is added displaying the counter value.

Example table

# color name city
white John New York
green Alice Warsaw
black Mark Rennes
{| class="wikitable sortable rownumber" 
!#
!color
!name
!city
|-
| class=rownumber-value |
| white
|John
|New York
|-
| class=rownumber-value |
|green
|Alice
|Warsaw
|-
| class=rownumber-value |
|black
|Mark
|Rennes
|}

This is what I add to my CSS page

When this below is on my vector.css page the above table has static row numbers.

User:Timeshifter/vector.css

/* Row numbering. Adapted from: 
/* http://www.mediawiki.org/w/index.php?title=User:Ciencia_Al_Poder/Test&oldid=588713 
/* See examples: http://en.wikipedia.org/wiki/User:Timeshifter/Sandbox33 */

table.rownumber {
	counter-reset: tablerownumber;
}
table.rownumber td.rownumber-value:before {
	content: counter(tablerownumber);
	counter-increment: tablerownumber;
}