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

Detailed explanation of the solution to forget the password in MySQL 5.7

ENV: [root@centos7 ~]# uname -r 3.10.0-514.el7.x8...

Summary of several replication methods for MySQL master-slave replication

Asynchronous replication MySQL replication is asy...

Grid systems in web design

Formation of the grid system In 1692, the newly c...

Pure CSS to modify the browser scrollbar style example

Use CSS to modify the browser scroll bar style ::...

Windows Service 2016 Datacenter\Stand\Embedded Activation Method (2021)

Run cmd with administrator privileges slmgr /ipk ...

Detailed tutorial on installing Prometheus with Docker

Table of contents 1. Install Node Exporter 2. Ins...

Detailed explanation of using split command to split Linux files

A few simple Linux commands let you split and rea...

Detailed steps to download Tomcat and put it on Linux

If you have just come into contact with Linux, th...

How to count the number of specific characters in a file in Linux

Counting the number of a string in a file is actu...

Double loading issue when the page contains img src

<br />When the page contains <img src=&qu...

Vue implements paging function

This article example shares the specific code of ...

MySQL data type selection principles

Table of contents Small but beautiful Keep it sim...

CSS performance optimization - detailed explanation of will-change usage

will-change tells the browser what changes will h...

Nginx high concurrency optimization practice

1. Necessity of Tuning​ I have always been reluct...

Linux MySQL root password forgotten solution

When using the MySQL database, if you have not lo...