عداد CSS () الوظيفة
مثال
قم بإنشاء عداد للصفحة (في محدد النص الأساسي). قم بزيادة قيمة العداد لكل عنصر <h2> ، وإضافة النص "القسم < قيمة العداد >:" قبل كل عنصر <h2>:
body {
counter-reset: section;
}
h2::before {
counter-increment: section;
content: "Section " counter(section) ": ";
}
المزيد من الأمثلة "جربها بنفسك" أدناه.
التعريف والاستخدام
ترجع الدالة counter () القيمة الحالية للعداد المسمى ، كسلسلة.
الإصدار: | CSS3 |
---|
دعم المتصفح
Function | |||||
---|---|---|---|---|---|
counter() | Yes | Yes | Yes | Yes | Yes |
بنية CSS
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) |
مزيد من الأمثلة
مثال
اضبط نمط العداد:
body {
counter-reset: section;
}
h2::before {
counter-increment: section;
content: "Section " counter(section,
upper-roman) ": ";
}
الصفحات ذات الصلة
مرجع CSS: خاصية المحتوى
مرجع CSS: خاصية زيادة العداد
مرجع CSS: خاصية إعادة التعيين العداد