• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • counter-reset

    版本:CSS3

    counter-reset 属性用于将 CSS计数器重置为制定值

    示例

    /* Set counter-name to 0 */
    counter-reset: counter-name;
    
    /* Set counter-name to -1 */
    counter-reset: counter-name -1;
    
    /* Set counter1 to 1, and counter2 to 4 */
    counter-reset: counter1 1 counter2 4;
    
    /* Cancel any reset that could have been set in less specific rules */
    counter-reset: none;
    
    /* Global values */
    counter-reset: inherit;
    counter-reset: initial;
    counter-reset: unset;
    

    浏览器支持

    IE浏览器火狐浏览器opera浏览器chrome浏览器safari浏览器
    IE8以上版本的浏览器都支持counter-reset

    语法

    counter-reset:[<custom-ident><integer>?]+| none

    取值

    • <custom-ident>:递增的计数器的名称。该标识符由不区分大小写的字母a~z,数字0~9,下划线(_)和/或短划线(-)的组合组成。第一个非破折号字符必须是一个字母(即,在它的开头没有数字,即使前面有破折号。)此外,在标识符的开头禁止使用两个破折号。在任何案例组合中都不能是noneunsetinitialinherit
    • <integer>:计数器的值。如果没有给出,默认为0。
    • none:该关键字表示不执行计数器重置。它可用于重置隐藏在不太具体的规则中定义的计数器。你可以指定要根据需要重置的计数器,每个计数器用空格分隔。

    你可以根据需要指定要递增的计数器,每个计数器用空格分隔。

    实例

    h1 {
      counter-reset: chapter section 1 page;
      /* Sets the chapter and page counters to 0
         and the section counter to 1. */
    }
    

    上篇:counter-increment

    下篇:counter-set