html中编号列表的html代码,如(a)

时间:2013-12-11 05:16:40

标签: html internet-explorer-7

我需要创建编号为(a),(b)等的列表元素....

我试过如下

<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上工作

2 个答案:

答案 0 :(得分:1)

IE 7解决方法(?)

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

通常,人们使用CSS计数器和&#34;:之前&#34;伪元素。

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/

答案 1 :(得分:0)

不,没有HTML方法可以生成编号,例如“(a)”。 type的{​​{1}}属性具有非常有限的值集。相应的CSS构造还有一些值,ol属性,但即便如此,也需要设置“数字”的样式,而不是围绕它们的标点符号。

现在常用的方法是使用CSS计数器和生成的内容,但这在IE 7上不起作用。

假设无法更改标记和内容,则只留下JavaScript方式。然后,您将替换list-style-type元素,例如通过ol元素,将div元素更改为li元素,其中包含“(a)”等内容,并使用合适的样式(边距)。