prefix
Baseline
2023
Newly available
Since September 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
Der prefix-Deskriptor der @counter-style-Regel spezifiziert den Inhalt, der am Anfang der Darstellung des Listenzeichenzählers hinzugefügt wird.
Wenn der Zählerwert negativ ist, kommt das prefix vor dem Minuszeichen und allen anderen <symbol>en, die durch den negative-Deskriptor hinzugefügt werden.
Syntax
/* <symbol> value: string, image, or identifier */
prefix: "»";
prefix: "Page ";
prefix: url("bullet.png");
Werte
Der prefix-Deskriptor nimmt als Wert ein einzelnes <symbol>:
<symbol>-
Gibt ein
<symbol>an — einen<string>,<image>oder<custom-ident>— das der Darstellung des Listenzeichenzählers vorangestellt wird.
Formale Definition
| Zugehörige @-Regel | @counter-style |
|---|---|
| Anfangswert | "" (the empty string) |
| Berechneter Wert | wie angegeben |
Formale Syntax
prefix =
<symbol>
<symbol> =
<string> |
<image> |
<custom-ident>
<image> =
<url> |
<image()> |
<image-set()> |
<cross-fade()> |
<element()> |
<gradient>
<image()> =
image( <image-tags>? [ <image-src>? , <color>? ]! )
<image-set()> =
image-set( <image-set-option># )
<cross-fade()> =
cross-fade( <cf-image># )
<element()> =
element( <id-selector> )
<image-tags> =
ltr |
rtl
<image-src> =
<url> |
<string>
<image-set-option> =
[ <image> | <string> ] [ <resolution> || type( <string> ) ]?
<cf-image> =
[ <image> | <color> ] &&
<percentage [0,100]>?
<id-selector> =
<hash-token>
Beispiele
>Hinzufügen eines Präfixes zu einem Zähler
In diesem Beispiel wird jeder Zählernummer "Book " (mit einem Leerzeichen) vorangestellt und gefolgt von einem Doppelpunkt (:). Der Doppelpunkt wird mit dem suffix-Deskriptor hinzugefügt.
HTML
<ol class="books">
<li>Flamer, by Mike Curato</li>
<li>Gender Queer: A Memoir, by Maia Kobabe</li>
<li>Tricks, by Ellen Hopkins</li>
<li>The Handmaid's Tale: The Graphic Novel, by Margaret Atwood</li>
<li>Crank, by Ellen Hopkins</li>
</ol>
CSS
@counter-style books {
system: numeric;
symbols: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9";
prefix: "Book ";
suffix: ": ";
}
.books {
list-style: books;
padding-left: 15ch;
}
Ergebnis
Spezifikationen
| Specification |
|---|
| CSS Counter Styles Level 3> # counter-style-prefix> |
Browser-Kompatibilität
Loading…
Siehe auch
- Andere
@counter-style-Deskriptoren:system,symbols,additive-symbols,negative,suffix,range,pad,speak-as, undfallback list-style,list-style-image,list-style-positionsymbols(): die funktionale Notation zur Erstellung anonymer Zählerstile- CSS-Zählerstile Modul
- CSS-Listen und -Zähler Modul