<ol>用数字另一种颜色 [英] <ol> with numbers another color

查看:22
本文介绍了<ol>用数字另一种颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    <li>测试</li><li>测试</li></ol>

将显示为:

  1. 测试
  2. 测试

我想要数字颜色和文本黑色!

我可以编辑 css,但我无法访问 HTML.

解决方案

CSSspec 给出了一个这样做的例子.不幸的是,虽然它适用于 Firefox 3,但它似乎不适用于 IE7:

<头><风格>ol { 计数器重置:项目;}ol li { 显示:块;}ol li:之前{内容:计数器(项目).";反增量:项目;红色;}</风格><身体><ol><li>项目</li><li>项目</li><li>项目</li></ol>

<ol>
   <li>test</li>
   <li>test</li>
</ol>

will show as:

  1. test
  2. test

I want to have numbers coloured and text black!

I can edit the css, but I do not have access to the HTML.

解决方案

The CSS spec gives an example of doing just this. Unfortunately, while it works on Firefox 3, it doesn't appear to work on IE7:

<html>
<head>
    <style>
        ol { counter-reset: item; }
        ol li { display: block; }
        ol li:before {
            content: counter(item) ". ";
            counter-increment: item;
            color: red;
        }
    </style>
</head>
<body>
    <ol>
        <li>item</li>
        <li>item</li>
        <li>item</li>
    </ol>
</body>
</html>

这篇关于&lt;ol&gt;用数字另一种颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆