找回密码
 快速注册
搜索
查看: 72|回复: 1

[MathJax]CSS counter编号

[复制链接]

3147

主题

8384

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65372
QQ

显示全部楼层

hbghlyj 发表于 2022-5-10 08:14 |阅读模式
  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>
复制代码
在Common HTML输出下可以看到效果:(在SVG下无效)

3147

主题

8384

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65372
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-5-10 08:32
使用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;

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 19:07

Powered by Discuz!

× 快速回复 返回顶部 返回列表