Detailed explanation of CSS counter related attributes learning

Detailed explanation of CSS counter related attributes learning

The CSS counter attribute is supported by almost all browsers (including IE8), but it is not often used. This article will show you how to learn about these attributes.

COUNTER-RESET

Clearly translated as counter reset. Such as: counter-reset: counter-name

Commonly written as

/* 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;

Used to reset the counter on an element

COUNTER-INCREMENT

Couter-increment is translated as counter reset

Commonly written as

/* Increment counter-name by 1 */
counter-increment: counter-name;

/* Decrement counter-name by 1 */
counter-increment: counter-name -1;

/* Increment counter1 by 1, and decrement counter2 by 4 */
counter-increment: counter 1 counter2 -4;

Before using counter-increment, we must first use counter-reset to initialize a counter in its parent element.

For example:

// parent element has a counter-reset
// applied to instantiate it
section {
  counter-reset: unicornCounter;
}

// specify the child element being counted
section h1 {
  counter-increment: unicornCounter;
}

In the above code, each h1 element of the section will be set to counted value 1

CSS syntax rules

COUNTER-RESET and COUNTER-INCREMENT have similar syntax

The first <custom-ident> indicates the specific counter identifier

Can be a word composed of az 0-9 _ - but cannot be a keyword none, unset, initial, or inherit

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

<<:  MySQL DATE_ADD and ADDDATE functions add a specified time interval to a date

>>:  Javascript scope and closure details

Recommend

Web page experience: Web page color matching

<br />The color of a web page is one of the ...

MySQL startup error InnoDB: Unable to lock/ibdata1 error

An error message appears when MySQL is started in...

In-depth analysis of MySQL data type DECIMAL

Preface: When we need to store decimals and have ...

Detailed explanation of CSS style sheets and format layout

Style Sheets CSS (Cascading Style Sheets) is used...

jQuery plugin to achieve code rain effect

This article shares the specific code of the jQue...

Analysis of MySQL data backup and recovery implementation methods

This article uses examples to describe how to bac...

How to install and use Cockpit on CentOS 8/RHEL 8

Cockpit is a web-based server management tool ava...

Detailed explanation of HTML form elements (Part 1)

HTML forms are used to collect different types of...

Practical record of handling MySQL automatic shutdown problems

I recently helped someone with a project and the ...

js to implement the snake game with comments

This article example shares the specific code of ...

jQuery treeview tree structure application

This article example shares the application code ...

Echarts Basic Introduction: General Configuration of Bar Chart and Line Chart

1Basic steps of echarts Four Steps 1 Find the DOM...