如何将括号(a)添加到有序列表中?兼容所有浏览器

Jit*_*yas 18 css xhtml jquery

我要表现得像

(一个)

(b)中

(C)

更新:

我发现了一种CSS方式

ol {list-style-type: none;}
li:before {content: "(" counter(section, lower-alpha) ") ";}
li { counter-increment: section;}
Run Code Online (Sandbox Code Playgroud)

但它不适用于IE 7及更低版本.

dec*_*eze 9

这可以通过自定义计数器实现,但至少IE7不支持它,其他一些也可能不支持.详情请见:http://www.quirksmode.org/css/counter.html

例如:

li:before {
    content: "(" counter(mycounter,lower-latin) ")";
}
Run Code Online (Sandbox Code Playgroud)


All*_*lan 5

我在启用CSS的mediawiki中使用此代码段。我不确定这是否可以在旧版的IE中使用...

{{#css:
  .laparent ol { counter-reset: item }
  .laparent li { display: block ; counter-increment: item; }
  .laparent li:before { content: " ("counter(item,lower-alpha)") "; }
}}
<ol class=laparent>
   <li> this is the first item;
   <li> this is the second item; or
   <li> this is the third item.
</ol>
Run Code Online (Sandbox Code Playgroud)

输出:

(a) this is the first item;
(b) this is the second item; or
(c) this is the third item. 
Run Code Online (Sandbox Code Playgroud)


Amy*_*y B 0

你无法得到(a)(b)(c)。

但是,您可以获得不带括号的字母:

<ul style="list-style-type: lower-latin;">...</ul>

请参阅http://www.w3schools.com/CSS/tryit.asp?filename=trycss_list-style-type_all