5

我试图弄清楚如何创建一个当前针对 IE6 和 IE7 的递增有序列表。

EG 它应该呈现如下内容:

1.0
    1.1
    1.2
    1.3
2.0
    2.1
    2.2

据我了解,这可以在 CSS 中创建,如下所示:

UL, OL { counter-reset: item; }
LI { display: block }
LI:before { content: counters(item, "."); counter-increment: item }

但是,当然,IE6 和 IE7 不支持这一点。

哪些选项可用于在 IE6/7 中创建适当的递增列表?我是否不得不硬编码这个。?不幸的是,使用 JavaScript 不是一种选择。

是否有适用于较新浏览器的更新方法?

4

4 回答 4

1

XSLT(包括 XSLT 1.0)可以使用<xsl:number>.

于 2009-03-02T15:27:24.613 回答
1

这是一个纯 CSS 的解决方案(应该在 IE8 及更高版本中工作):

<ol>
    <li>
        Heading
        <ol>
            <li>list</li>
            <li>list</li>
        </ol>
    </li>
    <li>
        Heading
        <ol>
            <li>list</li>
            <li>list</li>
        </ol>
    </li>
</ol>



ol{
    list-style-position:inside;
    list-style-type: none;
    counter-reset:mainNum;
}

ol li:before{
    content: counter(mainNum) ".0";
    counter-increment:mainNum;
}

ol ol{
    counter-reset:item;
}

ol ol li{
    list-style-type:none
}

ol ol li:before{
    content: counter(mainNum) "." counter(item) "  ";
    counter-increment:item;
}
于 2012-06-21T00:51:37.643 回答
0

如果 JavaScript 不是一个选项,您将不得不在服务器端对其进行硬编码/实现。

积极的一面是:它将立即适用于其他功能较弱的用户代理/设备(想想黑莓浏览器等)。

于 2009-03-02T15:26:29.917 回答
0

If javascript is not an option (and therefore also I assume no flash), I'm sorry to say you're out of options for a client-side solution. If you have a server-side script that is generating your HTML, you can push the ordering to the server and simply style the output on the client using CSS as an unordered-list with no bullet. IE6 is your limiting factor here, and there aren't many ways around that. Sorry to be the bearer of bad news.

于 2009-03-02T15:23:42.170 回答