စက်တင်စက်လုံးစား counter-set
- အရှေ့ပိုင်း counter-reset
- နောက်ပိုင်း @counter-style
အသုံးချက် နှင့် အပြုအရေး
counter-set
ဗီဇ သုံးသည်း လုံးဖော် ဖန်တီးပြီး လုံးဖော် ကို အမှတ်ပြုပါ:
counter-set
ဗီဇ သုံးသည်း လုံးဖော်-increment ဗီဇ နှင့် content ဗီဇ နှင့် အသုံးပြုပါ:
အမှတ်
အကျိုးသတ် 1
လုံးဖော် တစ်ခု ဖန်တီးပါ ("my-counter"), 5 အစားပြုပြီး <h2> ရှာဖွေစုံက်အား ဖြစ်ပါက 1 တိုးပါ:
body { /* "my-counter" ကို 5 အစားပြု */ counter-set: my-counter 5; } h2::before { /* 将 "my-counter" 增加 1 */ counter-increment: my-counter; content: "လုံးဖော် " counter(my-counter) ". "; }
အကျိုးသတ် 2
လုံးဖော် တစ်ခု ဖန်တီးပါ ("my-counter"), 5 အစားပြုပြီး <h2> ရှာဖွေစုံက်အား ဖြစ်ပါက 1 ကျဆင်းပါ:
body { /* "my-counter" ကို 5 အစားပြု */ counter-set: my-counter 5; } h2::before { /* "my-counter" ကို 1 ကျဆင်း */ counter-increment: my-counter -1; content: "လုံးဖော် " counter(my-counter) ". "; }
အကျိုးသတ် 3
လုံးဖော် အချက်အလက်: "လုံးဖော် 10:"、"10.1"、"10.2" စသည့် ပုံစံဖြင့် လုံးဖော် နှင့် လုံးဖော် အသုံးပြုပါ:
body { /* "လုံးဖော်" ကို 9 အစားပြု */ counter-set: လုံးဖော် 9; } h1 { /* 将 "subsection" 设置为 0 */ counter-set: subsection 0; } h1::before { /* 将 "section" 增加 1 */ counter-increment: section; content: "Section " counter(section) ": "; } h2::before { /* 将 "subsection" 增加 1 */ counter-increment: subsection; content: counter(section) "." counter(subsection) " "; }
例子 4
创建一个计数器,将其设置为 9,并在每次出现
选择器时将其增加 1(使用罗马数字):
body {
/* 将 "my-counter" 设置为 9 */
counter-set: my-counter 9;
}
h2::before {
/* 将 "my-counter" 增加 1 */
counter-increment: my-counter;
content: counter(my-counter, upper-roman) ". ";
}
CSS 语法
counter-set: none|counter-name number|initial|inherit;
属性值
值 | 描述 |
---|---|
none | 默认值。不设置计数器。 |
counter-name number |
要设置的计数器名称及其值。 每次出现选择器时,计数器将被设置为该值。 默认数值为 0。 |
initial | 将此属性设置为其默认值。参阅 initial。 |
inherit | 从其父元素继承此属性。参阅 inherit。 |
默认值: | none |
---|---|
继承性: | 否 |
动画制作: | 不支持。请参阅:动画相关属性。 |
版本: | CSS2 |
JavaScript 语法: | object.style.counterSet="4" |
浏览器支持
表格中的数字注明了完全支持该属性的首个浏览器版本。
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
85 | 85 | 68 | 17.2 | 71 |
လုပ်ကိုင် စာကြိုး
လျှက်ချက်::before အကွက် ပုံစံအဖွဲ့
လျှက်ချက်::after အကွက် ပုံစံအဖွဲ့
လျှက်ချက်စက်တင်စက်လုံးစား content
လျှက်ချက်စက်တင်စက်လုံးစား counter-increment
- အရှေ့ပိုင်း counter-reset
- နောက်ပိုင်း @counter-style