css 实现计数器_CSS计数器入门

css 实现计数器

As web developers, proper representation of information is an important feature. One way to properly display information is by denoting hierarchy, answering the question of "what comes first?".

作为Web开发人员,正确表示信息是一项重要功能。 正确显示信息的一种方法是表示层次结构,回答“先来什么?”的问题。

One sure way to denote hierarchy is by numbering objects. Apart from the ordered list, there is no other element that allows us to increment order in CSS. If we wanted to display numbers like we have above, we had to do some preprocessing. Keeping track of the index, making sure to auto-increment it etc. Something like this.

表示层次结构的一种可靠方法是对对象编号。 除了有序列表之外 ,没有其他元素可以让我们增加CSS的顺序。 如果要像上面一样显示数字,则必须进行一些预处理。 跟踪索引,确保自动递增等。类似这样的事情。

<ul class="numbered-list">
    <?php for ($i = 1; $i <= $posts->total_count; $i++): ?>
    <li class="numbered-list__item">
        <span class="numbered-list__counter">
            <?php echo $i ?>
        </span>
        <!-- Remaining markup -->
    </li>
    <?php endfor ?>
</ul>

This is good up to a point, but it has its limitations. What if we wanted to use alphabets, Roman numerals, Greek characters like etc. Implementing any of this requires the use of custom libraries.

在某种程度上,这是好的,但是它有其局限性。 如果我们想使用字母,罗马数字,希腊字符之类的话,该怎么办。要实现这些功能,都需要使用自定义库。

Thankfully, with CSS we can keep track of things like this without breaking a sweat.

幸运的是,借助CSS,我们可以不遗余力地跟踪此类事件。

计数器重置和计数器增量 (

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值