CSS sayacı() İşlev
Örnek
Sayfa için bir sayaç oluşturun (gövde seçicide). Her <h2> öğesi için sayaç değerini artırın ve her <h2> öğesinin önüne "Bölüm < sayacın değeri >:" metnini ekleyin :
body {
counter-reset: section;
}
h2::before {
counter-increment: section;
content: "Section " counter(section) ": ";
}
Aşağıda daha fazla "Kendiniz Deneyin" örnekleri.
Tanım ve Kullanım
counter() işlevi, adlandırılmış sayacın geçerli değerini bir dize olarak döndürür.
Sürüm: | CSS3 |
---|
Tarayıcı Desteği
Function | |||||
---|---|---|---|---|---|
counter() | Yes | Yes | Yes | Yes | Yes |
CSS Sözdizimi
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) |
Daha fazla örnek
Örnek
Sayacın stilini ayarlayın:
body {
counter-reset: section;
}
h2::before {
counter-increment: section;
content: "Section " counter(section,
upper-roman) ": ";
}
İlgili Sayfalar
CSS referansı: içerik özelliği
CSS referansı: karşı artış özelliği
CSS referansı: sayaç sıfırlama özelliği