CSS teller() Funksie
Voorbeeld
Skep 'n teller vir die bladsy (in die liggaamkieser). Verhoog die tellerwaarde vir elke <h2>-element, en voeg die teks "Afdeling < waarde van die teller >:" voor elke <h2>-element by:
body {
counter-reset: section;
}
h2::before {
counter-increment: section;
content: "Section " counter(section) ": ";
}
Meer "Probeer dit self" voorbeelde hieronder.
Definisie en gebruik
Die teller()-funksie gee die huidige waarde van die genoemde teller terug, as 'n string.
Weergawe: | CSS3 |
---|
Blaaierondersteuning
Function | |||||
---|---|---|---|---|---|
counter() | Yes | Yes | Yes | Yes | Yes |
CSS-sintaksis
counter(countername,
counterstyle)
Value | Description |
---|---|
countername | Required. The name of the counter (which is the same name used for the counter-reset and counter-increment properties) |
counterstyle | Optional. The style of the counter (can be a list-style-type value) |
Meer voorbeelde
Voorbeeld
Stel die styl van die toonbank:
body {
counter-reset: section;
}
h2::before {
counter-increment: section;
content: "Section " counter(section,
upper-roman) ": ";
}
Verwante bladsye
CSS verwysing: inhoud eiendom
CSS verwysing: teen-inkrement eiendom
CSS verwysing: teen-terugstel eiendom