2014-02-27 38 views
3

我想使用class顯示如下的訂單清單。我已經嘗試過,但它沒有工作,請幫助我如何才能做到這一點?訂單清單不能與ol type =「a」

1. List item 
    1.1 list item 
     (a) lit item a 
     (b) list item b 
2. List item 
    2.1 list item 
     (a) lit item a 
     (b) list item b 



.listStyle08 { 
    counter-reset: item; 
} 
.listStyle08 ol { 
    counter-reset: item; 
} 
.listStyle08 li { 
    display: block; 
} 
.listStyle08 li:before { 
    content: counters(item, ".") " "; 
    counter-increment: item; 
    display: inline-block !important; 
    padding-right: 10px; 
} 
+0

您可以創建一個jsfiddl è? –

+0

什麼是您的HTML標記,以及CSS代碼如何反映您嘗試實現您所描述的演示文稿? –

回答

4

這裏是a jsfiddle與一個工作解決方案。

的樣式複製在這裏爲了方便:

ol { 
    counter-reset: section; 
    list-style-type: none; 
} 
li:before { 
    counter-increment: section; 
    content: counters(section, ".") ". "; 
} 

li li:before { 
    counter-increment: section; 
    content: counters(section, ".") " "; 
} 

ol ol ol { 
    counter-reset: list; 
    margin: 0; 
} 

ol ol ol > li { 
    list-style: none; 
    position: relative; 
} 

ol ol ol > li:before { 
    counter-increment: list; 
    content: "(" counter(list, lower-alpha) ") "; 
    position: absolute; 
    left: -1.4em; 
} 

來源:

+0

我願意使用類來做這件事,因爲我使用不同類型的訂單列表,例如。 1.列表項1.1子列表項(i)子子列表項,我如何使用類做上面的解決方案? –

+0

只是以我的類名稱爲前綴的選擇器,例如用'.listStyle08 ol'代替'ol' – bejonbee

+0

其不工作http://jsfiddle.net/rqhK9/15/ –