Html段号

时间:2010-09-03 14:15:47

标签: html

我如何格式化HTML中显示的文本,如下所示:

1.1 cdashjkfhkdvfsdfjkvnjk
    cnzxjkvnkncjkvjkxcvbkcbvk
1.2 cnzxjknvjn jvnxcjkcxcx
    klczxkcnzxnclnxknckxnk
1.3 ....

而不是这些:

       1.  cdashjkfhkdvfsdfjkvnjk cnzxjkvnkncjkvjkxcvbkcbvk cnzxjkvnkncjkvjkxcvbkcbvk 
cnzxjkvnkncjkvjkxcvbkcbvk cnzxjkvnkncjkvjkxcvbkcbvk cnzxjkvnkncjkvjkxcvbkcbvk cnzxjkvnkncjkvjkxcvbkcbvk
       2. cdashjkfhkdvfsdfjkvnjk cnzxjkvnkncjkvjkxcvbkcbvk

任何想法????

2 个答案:

答案 0 :(得分:3)

使用有序列表。

<ol>
    <li>cdashjkfhkdvfsdfjkvnjk cnzxjkvnkncjkvjkxcvbkcbvk </li>
    <li>cdashjkfhkdvfsdfjkvnjk cnzxjkvnkncjkvjkxcvbkcbvk </li>
</ol>
<ol>
    <li>cdashjkfhkdvfsdfjkvnjk cnzxjkvnkncjkvjkxcvbkcbvk </li>
    <li>cdashjkfhkdvfsdfjkvnjk cnzxjkvnkncjkvjkxcvbkcbvk </li>
</ol>

修改

如果您不关心IE6,以下内容将起作用= P

body {
    counter-reset:section;
}
ol {
    counter-increment:section;
    counter-reset:subsection;
}
li:before {
    counter-increment:subsection;
    content:counter(section) "." counter(subsection) " ";
}

<强>输出:

1.1 cdashjkfhkdvfsdfjkvnjk cnzxjkvnkncjkvjkxcvbkcbvk </li>
1.2 cdashjkfhkdvfsdfjkvnjk cnzxjkvnkncjkvjkxcvbkcbvk </li>
2.1 cdashjkfhkdvfsdfjkvnjk cnzxjkvnkncjkvjkxcvbkcbvk </li>
2.2 cdashjkfhkdvfsdfjkvnjk cnzxjkvnkncjkvjkxcvbkcbvk </li>

http://jsfiddle.net/73vp5naf/

答案 1 :(得分:0)

据我所知,浏览器不会为你做小数。

你可以使用两个有序列表,一个在另一个里面,内部有一个字母或罗马数字?

E.g。

<ol>
    <li>Part 1</li>
    <ol>
        <li>Child 1 of Part 1</li>
        <li>Child 2 of Part 1</li>
    </ol>
    <li>Part 2</li>
    <ol>
        <li>Child 1 of Part 2</li>
        <li>Child 2 of Part 2</li>
    </ol>
</ol>