Forgot password?
 Create new account
View 127|Reply 1

[MathJax]CSS counter编号

[Copy link]

3147

Threads

8497

Posts

610K

Credits

Credits
66183
QQ

Show all posts

hbghlyj Posted at 2022-5-10 08:14:46 |Read mode
  1. <style>body{counter-reset: section;}
  2. .counter {
  3.   position: absolute;
  4.   right: 0;
  5.   counter-increment: section;
  6.   line-height:normal
  7. }
  8. .counter::after {
  9.   content: "("counter(section)")";
  10. }
  11. </style>
Copy the Code
在Common HTML输出下可以看到效果:(在SVG下无效)

3147

Threads

8497

Posts

610K

Credits

Credits
66183
QQ

Show all posts

 Author| hbghlyj Posted at 2022-5-10 08:32:09
使用CSS计数器
counter-reset 属性用于将 CSS计数器 重置为制定值
例如
counter-reset: chapter-count 0;
counter-reset: chapter-count 5;
counter-reset: chapter-count -5;

counter-increment属性用于将CSS Counters的值增加给定值。
/*将计数器的值增加1*/
counter-increment: counter-name;
/*将counter的值增加1 将counter2的值减少4*/
counter-increment: counter 1 counter2 -4;

手机版Mobile version|Leisure Math Forum

2025-4-21 01:24 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list