Để tăng giá trị bộ đếm bằng CSS, hãy sử dụng counter-increme nt tài sản.
Bạn có thể thử chạy mã sau để triển khai triển khai phản đối tài sản -
Ví dụ
<!DOCTYPE html> <html> <head> <style> body { counter-reset: section; } h2::before { counter-increment: section; content: "Fruit " counter(section) " - "; } </style> </head> <body> <h1>Fruits</h1> <h2>Mango</h2> <h2>Kiwi</h2> </body> </html>