2013-12-11 31 views
0

我需要創建與編號爲(a),(b)中,等....HTML代碼(一)

我試圖如下列表元素

<ol type="a"> 
<li>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
</li> 
<li> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
</li> 
</ol> 

但不是有一個。 ...和b。 ...我想(a)...和(b)...

是否有一種特殊類型的編號字母列表括號?

需要它的IE7也

回答

1

IE 7解決方法工作

var i =0; 
                 // A is #65 in Unicode 
$("ol").children() 
     .prepend('<span class="li-counter">(' + String.fromCharCode(64+(i++)) + ')'); 

Generaly,人們使用CSS計數器和(?):僞元素 「之前」。

ol { 
    counter-reset: my-counter; 
} 
ol li:before { 
    content: "(" counter(my-counter, lower-alpha) ")"; 
    counter-increment: my-counter; 
    margin-right: 5px; 
    font-weight: bold; 

}

有關於自定義一個類似的問題OL編號: Ordered list (HTML) lower-alpha with right parentheses?

http://jsfiddle.net/dd63m/10/

+0

謝謝,但該溶液不工作在IE7 –

+0

+1相關答案 –

0

沒有,沒有HTML的方式來產生編號,如「(一)」 。 ol的屬性type具有非常有限的一組值。對於相應的CSS構造還有一些更多的值,即使對於它,也是設置「數字」樣式的問題,而不是圍繞它們標點符號。

通常的做法是時下使用CSS計數器和生成的內容,但是,這並不在IE 7

工作假設標記和內容不能改變,這種只保留了JavaScript的方式。然後,您將替換例如ol元素。由div元素組成,其中li元素更改爲div元素,其內容類似於「(a)」,並帶有適當的樣式(邊距)。