html中正方形前缀样式列表,列表添加数字序列号前缀,css解决方案!

昨天一个模板用户咨询我关于列表增加数字序列号,比如 1 2 3 ...这样的前缀,但代码中并不能生成前缀数字,或者懒的去弄,想直接用css解决,其实方案还是有的,并且现在还算比较方便!

下面分享出来:

Project Goals

  1. Build a website that is easy to use and easy to maintain
  2. Begin using a constituent database to consolidate all information about members, donors and audiences
  3. Offer users a way to register and pay for classes online
  4. Establish a consistent brand for website and print materials
@import url(http://fonts.googleapis.com/css?family=Lato|Bree+Serif);

body {

background: white;

}

*,

*:before,

*:after {

box-sizing: border-box;

}

.wrapper {

margin: 2em auto;

width: 90%;

max-width: 1000px;

}

h2 {

font-family: "Bree Serif", serif;

}

ol {

counter-reset: li;

margin: 0;

padding: 0;

}

ol > li {

font-family: "Lato", sans;

font-size: 1.3em;

list-style: none;

margin: 0 0 0.5em 1.95em;

padding: 0.5em 1em;

position: relative;

}

ol > li:before {

background: #8da97d;

color: white;

content: counter(li);

counter-increment: li;

font-family: "Bree Serif", serif;

font-size: 1.2em;

line-height: 1em;

padding: 0.5em 0;

position: absolute;

top: 0.4em;

left: -1.6em;

text-align: center;

width: 2em;

}

效果:

4e06a169c9bc784775eff0bb0d1a3599.png

这个方式最简单,直接用css解决数字序列号前缀!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值