如何在html列表上设置数字样式?

Fil*_*ype 20 css html-lists

是否可以在有序列表上设置或增加数字的大小?

我打算只使用CSS 将有序列表ol转换为类似wikihow的步骤.

以下是一个例子:http://jsfiddle.net/ejRzy/1/

rle*_*mon 43

它可以使用CSS3但不是100%跨浏览器(即IE7)来完成.使用伪:before元素和counter-reset以及counter-increment,你可以隐藏list-style并创建自己的.

这是一篇文章,概述了如何:样式有序列表编号

这里是那篇文章建立了一个演示.

同样在可怕的链接腐烂的情况下 - 这是所需的主要CSS代码(这可以应用于任何有序列表)

ol {
    counter-reset:li; /* Initiate a counter */
    margin-left:0; /* Remove the default left margin */
    padding-left:0; /* Remove the default left padding */
}
ol > li {
    position:relative; /* Create a positioning context */
    margin:0 0 6px 2em; /* Give each list item a left margin to make room for the numbers */
    padding:4px 8px; /* Add some spacing around the content */
    list-style:none; /* Disable the normal item numbering */
    border-top:2px solid #666;
    background:#f6f6f6;
}
ol > li:before {
    content:counter(li); /* Use the counter as content */
    counter-increment:li; /* Increment the counter by 1 */
    /* Position and style the number */
    position:absolute;
    top:-2px;
    left:-2em;
    -moz-box-sizing:border-box;
    -webkit-box-sizing:border-box;
    box-sizing:border-box;
    width:2em;
    /* Some space between the number and the content in browsers that support
       generated content but not positioning it (Camino 2 is one example) */
    margin-right:8px;
    padding:4px;
    border-top:2px solid #666;
    color:#fff;
    background:#666;
    font-weight:bold;
    font-family:"Helvetica Neue", Arial, sans-serif;
    text-align:center;
}
li ol,
li ul {margin-top:6px;}
ol ol li:last-child {margin-bottom:0;}?
Run Code Online (Sandbox Code Playgroud)

此代码将生成自定义有序列表; 虽然不是你要求的风格.我会把定制工作留给你:)干杯


Kei*_*las 13

....使用您想要的数字字体大小来定制您的有序列表,然后将所有列表项包装在跨度中,并为它们提供不同的样式.

http://jsfiddle.net/keith_nicholas/MEHXj/

  • 当然,但是本着stackoverflow的精神,我们不会停止它是不可能的,我们开始寻找我们可以绕过事物来实现我们想要的方式:) (4认同)