counter-set
Misol
Hisoblagich ("my-counter") yarating, uni 5 ga o‘rnating va <h2> selektori har safar uchraganda uni bittaga oshiring:
body {
/* Set "my-counter" to 5 */
counter-set: my-counter 5;
}
h2::before {
/* Increment "my-counter" by 1 */
counter-increment: my-counter;
content: "Section " counter(my-counter) ". ";
}
O‘zingiz sinab ko‘ring »
Quyida ko‘proq "O‘zingiz sinab ko‘ring" misollari keltirilgan.
Ta’rif va qo‘llanilishi
counter-set xususiyati CSS hisoblagichini yaratadi va uni ma’lum bir qiymatga o‘rnatadi.
counter-set xususiyati odatda counter-increment va content xususiyatlari bilan birga ishlatiladi.
| Standart qiymat: | none |
|---|---|
| Meros qilinadi: | yo‘q |
| Animatsiya qilinadi: | yo‘q. animatable haqida o‘qing |
| Versiya: | CSS2 |
| JavaScript sintaksisi: | object.style.counterSet="4" Sinab ko‘ring |
Brauzerlarda qo‘llab-quvvatlash
Jadvaldagi sonlar xususiyatni to‘liq qo‘llab-quvvatlaydigan birinchi brauzer versiyasini ko‘rsatadi.
| Xususiyat | |||||
|---|---|---|---|---|---|
| counter-set | 85 | 85 | 68 | 17.2 | 71 |
CSS sintaksisi
counter-set: none|counter-name number|initial|inherit;
Xususiyat qiymatlari
| Qiymat | Tavsif |
|---|---|
| none | Standart qiymat. Hech qanday hisoblagich o‘rnatilmaydi |
| counter-name number | O‘rnatiladigan hisoblagich nomi va selektor har safar uchraganda hisoblagichga beriladigan qiymat. Standart number qiymati — 0 |
| initial | Bu xususiyatni standart qiymatiga o‘rnatadi. initial haqida o‘qing |
| inherit | Bu xususiyatni ota elementidan meros qilib oladi. inherit haqida o‘qing |
Ko‘proq misollar
Misol
Hisoblagich ("my-counter") yarating, uni 5 ga o‘rnating va <h2> selektori har safar uchraganda uni bittaga kamaytiring:
body {
/* Set "my-counter" to 5 */
counter-set: my-counter 5;
}
h2::before {
/* Decrement "my-counter" by 1 */
counter-increment: my-counter -1;
content: "Section " counter(my-counter) ". ";
}
O‘zingiz sinab ko‘ring »
Misol
Bo‘lim va kichik bo‘limlarni "Section 10:", "10.1", "10.2" va hokazo tarzda raqamlash:
body {
/* Set "section" to 9 */
counter-set: section 9;
}
h1 {
/* Set "subsection" to 0 */
counter-set: subsection 0;
}
h1::before {
/* Increment "section" by 1 */
counter-increment: section;
content: "Section " counter(section) ": ";
}
h2::before {
/* Increment "subsection" by 1 */
counter-increment: subsection;
content: counter(section) "." counter(subsection) " ";
}
O‘zingiz sinab ko‘ring »
Misol
Hisoblagich yarating, uni 9 ga o‘rnating va <h2> selektori har safar uchraganda uni bittaga oshiring (rim raqamlaridan foydalanib):
body {
/* Set "my-counter" to 9 */
counter-set: my-counter 9;
}
h2::before {
/* Increment "my-counter" by 1 */
counter-increment: my-counter;
content: counter(my-counter, upper-roman) ". ";
}
O‘zingiz sinab ko‘ring »
Tegishli sahifalar
CSS ma’lumotnomasi: ::before psevdo-elementi
CSS ma’lumotnomasi: ::after psevdo-elementi
CSS ma’lumotnomasi: content xususiyati
CSS ma’lumotnomasi: counter-increment xususiyati
CSS funksiyalari: counter() funksiyasi
W3Schools Pathfinder
Yutuqlaringizni kuzating – bu bepul!
