카테고리 없음

[css]counter-increment

FaustK 2020. 4. 29. 01:34

주석과 이미지를 보면 이해할 수 있다~

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      body {
        counter-reset: num; /* num 을 0으로 초기화 */
      }

      h3::before {
        counter-increment: num; /* 1증가 */
        content: counter(num) '. '; /* 표시 */
      }
    </style>
  </head>
  <body>
    <h3>HTML</h3>
    <h3>CSS</h3>
    <h3>JavaScript</h3>
  </body>
</html>