Skip to content

Instantly share code, notes, and snippets.

@ryozi-tn
Created March 6, 2016 16:21
Show Gist options
  • Save ryozi-tn/5496e56e9141a5559f5b to your computer and use it in GitHub Desktop.
Save ryozi-tn/5496e56e9141a5559f5b to your computer and use it in GitHub Desktop.
contenteditableの領域に項番を出したいけど編集できないようにしたい.md

目的

contenteditableの領域に項番を出したいけど編集できないようにしたい.md

案1. ol-li Elementを使うよ派

https://jsfiddle.net/gtxhLoue/

  • 良い点
    • ちゃんとできてる(ようにみえる)
    • CSS2の範疇なのでブラウザサポートが期待できる
  • 悪い点
    • 変な使い方じゃない・・・?
    • 階層構造が複雑になったらどうなる?ol-li-ol-li...が守られているうちは動くが・・・ol-li-div-ol-li...みたいになったら?

案2. attributeに埋め込んでCSSで見せるよ派

https://jsfiddle.net/y18ddvap/

  • 良い点
    • 階層が変になろうがattributeをしっかり振っていればちゃんと動く
  • 悪い点
    • 項番の管理が手動(html生成するプログラムで面倒見る必要がある)
    • before疑似要素でattr()してもよいのはCSS3かららしい。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment