如何在有序列表中添加括号(a)? 兼容所有浏览器
我必须表现出来
(一个)
(b)中
(C)
更新:
我发现了一种CSS方式
ol {list-style-type: none;} li:before {content: "(" counter(section, lower-alpha) ") ";} li { counter-increment: section;}
但它不适用于IE 7及更低版本。
这可以通过自定义计数器实现,但至少IE7不支持它,其他一些也可能不支持。 详情请见: http : //www.quirksmode.org/css/counter.html
例如:
li:before { content: "(" counter(mycounter,lower-latin) ")"; }
我在启用CSS的mediawiki中使用此代码段。 我不确定这是否适用于旧版本的IE …
{{#css: .laparent ol { counter-reset: item } .laparent li { display: block ; counter-increment: item; } .laparent li:before { content: " ("counter(item,lower-alpha)") "; } }} - this is the first item;
- this is the second item; or
- this is the third item.
输出:
(a) this is the first item; (b) this is the second item; or (c) this is the third item.
从CSS3开始问题就解决了:
style="list-style-type: parenthesized-lower-latin;"
你不能得到(a)(b)(c)。
但是你可以收到没有括号的信件:
- ...
请参阅http://www.w3schools.com/CSS/tryit.asp?filename=trycss_list-style-type_all
根据W3C, 这些是您的选择 。
使用CSS是不可能的。 您必须使用javascript(或类似)制作自定义列表。
没有内置的方法来做到这一点。 这意味着你进入(有趣)黑客的土地。
您可以尝试两个括号的背景图像。
我代替了段落。 我缩进了段落然后拉出第一行,使用文本缩进并自己编号。
.list_indent { margin-left:48px; } .list_indent p { text-indent:-26px; } (1) The recruitment report and a copy of the blah and blah and blah and blah and blah and blah and blah and blah.;
(2) A copy of the blah and blah and blah and blah and blah and blah and blah and blah.
(3) Recruitment.
或者您可以手动添加文本计数,而无需担心浏览器回退。 适用于任何浏览器!
ul.abc-list { list-style: none; padding-left: 30px; } ul.abc-list > li > span.counter { position: absolute; margin-left: -20px; /*if you want to right align the text * * width: 15px; * text-align: right; */ }
- a) One
- b) Two
- c) Three
- d) Four
- e) Five