Get the App
SLTechnology News&Howtos  ›  Development  › 

How does css use counter () to automatically add serial numbers to the list

Shulou Source: shulou.com Published: 2022-06-01 04:59:00 11月23日 Update

Editor to share with you how css uses counter () to automatically add serial numbers to the list, I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it together.

Use counter () to automatically add sequence numbers to the list

Another feature already supported in CSS 2.1is counter (), which makes it easy to add serial numbers to page titles, blocks, and other consecutive page content. With it, you don't have to be limited to use to achieve this effect, you can use custom number sequences on the page more flexibly.

The point is that it's really simple: add counter () to the content attribute in the before pseudo class:

Body {countercounter-reset: heading;} h4:before {countercounter-increment: heading; content: "Heading #" counter (heading) ".";} above is all the content of the article "how to use counter () to automatically add serial numbers to the list". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Serial number content article page not much key function block most that is attribute sequence effect number more title knowledge industry information information channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Xiaomi Shulou Information Apple MariaDB