【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 / 2019.9.6
- LINE風の吹き出しの会話をCSSで作ってみる
- web / 2019.5.10
- 【CSS】ローディングアニメーション実装サンプル集
- web / 2018.10.26
- 【CSS】ラインの下に三角の影をつくる
Googleさんのおすすめ
人気記事
- web / 2019.4.16
- 【CSS】ハンバーガーメニュー実装サンプル集(クリック時のエフェクトも集めました)
- web / 2022.2.1
- 【jQuery】アコーディオン実装サンプル10選
- web / 2019.9.27
- 【jQuery】スライダープラグイン「slick」実装サンプル集
Googleさんのおすすめ
デザインの記事
- 2023.03.24New
- JANAI COFFEE
- 国内、海外のウェブデザイン、パソコン・タブレット・スマートフォンでも見やすいレスポンシブ対応の「あ、いいな」と思うウェブデザインを集めています。
- デザインのこと – Web design gallery
- 2022.06.15
- ちょっと思い出しただけ
- (C)2022『ちょっと思い出しただけ』製作委員会 もくじ 『ちょっと思い出しただけ』 あ…
- いつかのこと – 無印良品の家と暮らす
- 2023.02.23
- 【CSS】『shape-outside』でテキストの回り込みを円形にしてみる
- 文章の回り込みって丸くできないですかー? あー、円形に回り込みですねー、できますよ…
- 125naroom / デザインするところ(会社)です。