2011-10-17 14 views

答えて

8

はい、少なくとも現代のブラウザで:

li li:before { 
    counter-increment: item; 
    content: counter(item) ". "; 
} 

(。li liがあるので、それだけで、これは最初のレベルの後に行います)

あなたはおそらく同様にcounter-resetが必要になります。

+0

これは動作しますか?ニース! – knittl

+0

ありがとう、アリエル。私はこれを機能させるためにもう少し追加しました。 – Rocky

+0

しかし、私たちはこれのためにあらゆるレベルを扱う必要があります。少し迷惑な。 HTML5はこれをよりうまく処理しますか? – Rocky

0
body 
{ 
    counter-reset:section; 
} 

h1 
{ 
    counter-reset:subsection; 
} 

h1:before 
{ 
    counter-increment:section; 
    content:"Section " counter(section) ". "; 
} 

h2:before 
{ 
    counter-increment:subsection; 
    content:counter(section) "." counter(subsection) " "; 
} 
body 
{ 
    counter-reset:section; 
} 

これはカウンタインクリメントとカウンタリセットのサンプルです。

13

このソリューションは、私の作品:

/* hide original list counter */ 
ol li {display:block;} 
/* OR */ 
ol {list-style:none;} 

ol > li:first-child {counter-reset: item;} /* reset counter */ 
ol > li {counter-increment: item;} /* increment counter */ 
ol > li:before {content:counters(item, ".") ". "; font-weight:bold;} /* print counter */ 
+0

コードを少し修正して私の好みに合わせました。それは別の同様の質問に位置しています:http://stackoverflow.com/questions/4098195/can-ordered-list-produce-result-that-looks-like-1-1-1-2-1-3-instead- of-just-1/25298818#25298818 – chelder

関連する問題