html网页字段序号的样式,css – 如何在html列表中编号?

它可以使用CSS3而不是100%的跨浏览器(即IE7)完成。使用伪:before元素和counter-reset和counter-increment可以隐藏列表风格并创建自己的。

而here是从该文章构建的演示。

另外在可怕的链接腐败的情况下 – 这里是所需的主要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;}​

该代码将产生一个定制的订单列表;虽然不是你要求的风格。我会离开定制工作给你:)欢呼

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值