【CSS】counter-incrementを使って擬似要素をリスト化する
- 2019.3.28
- CSS

ワードプレスのランキング表示で役立ったメモ。
擬似要素でリスト化する。
サンプル
1段目/1からはじまる
2段目/0からはじまる
3段目/01からはじまる
4段目/001からはじまる
See the Pen
CSS / counter-increment by 125naroom (@125naroom)
on CodePen.
CSS
1からはじまる
div section { counter-increment: section; } div section:before { content: counter(section); }
0からはじまる
div section:nth-of-type(1) { counter-reset: section; } div section:not(:nth-of-type(1)) { counter-increment: section; } div section:before { content: counter(section); }
01からはじまる
div section { counter-increment: section; } div section:before { content: counter(section, decimal-leading-zero); }
001からはじまる
div section { counter-increment: section; } div section:before { content: '0' counter(section, decimal-leading-zero); } div section:nth-of-type(99) ~ section:before { content: counter(section, decimal-leading-zero); }
おすすめ
かんれん
- web / 2018.8.29
- 【CSS】px(ピクセル)とem(エム)
- web / 2019.1.17
- 【CSS】プラスとマイナスをつくる
- web / 2020.1.15
- 【CSS】簡単に固定できるposition: sticky;の実装サンプル集
Googleさんのおすすめ
人気記事
- web / 2019.4.16
- 【CSS】ハンバーガーメニュー実装サンプル集(クリック時のエフェクトも集めました)
- web / 2022.2.1
- 【jQuery】アコーディオン実装サンプル10選
- web / 2019.9.27
- 【jQuery】スライダープラグイン「slick」実装サンプル集
Googleさんのおすすめ
デザインの記事
- 2023.09.29New
- センダイパルコ15th | 仙台PARCO
- 国内、海外のウェブデザイン、パソコン・タブレット・スマートフォンでも見やすいレスポンシブ対応の「あ、いいな」と思うウェブデザインを集めています。
- デザインのこと – Web design gallery
- 2022.06.15
- ちょっと思い出しただけ
- (C)2022『ちょっと思い出しただけ』製作委員会 もくじ 『ちょっと思い出しただけ』 あ…
- いつかのこと – 無印良品の家と暮らす
- 2023.07.31
- 【Google Chrome】ショートカットキーまとめ(Windows or Mac)
- クロームでF5(更新)ってどうするんでしたっけ? あー、Macですか?わかるわかる、な…
- 125naroom / デザインするところ(会社)です。