LoginSignup
8
4

More than 5 years have passed since last update.

[CSS] 番号付きリストの『番号』だけ色を変更する方法

Posted at
CSS
<ol>
    <li>一つ目のリストです</li>
    <li>二つ目のリストです</li>
    <li>三つ目のリストです</li>
    <li>四つ目のリストです</li>
    <li>五つ目のリストです</li>
</ol>
CSS
ol {
    counter-reset: li;    /* li のカウンタを 0 にセット */ 
    list-style: none;
}

li:before {
    color: #f00;
    font-weight: bold;
    counter-increment: li;   /* li の数を一つずつ増加 */
    content: counter(li) ". ";          /* 数を表示 */
}

参考元:【CSS】counterを使って番号付きリストの『番号』だけ色を変更する方法 | キノめも

8
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
4