Can I style numbering an ordered list that has a start attribute value?

前端 未结 4 738
小鲜肉
小鲜肉 2020-12-20 23:27

Here\'s the problem:

I have an ol li ordered list with a start attribute like so:

4条回答
  •  情书的邮戳
    2020-12-21 00:21

    Here is my jank solution.

    Prepend with js x li's at the beginning of the ol. Then hide them by positionning them absolute and throwing them to the moon.

    $('ol[start]').each(function(){
        var start = $(this).attr('start');
        //console.log(start);
        for(var i=1;i
  • '); } })
        
    ol{
      counter-reset: items;
      padding:0;
      padding-left: 46px;
    }
    ol  li {
      display: block;
      counter-increment: items;
      text-indent: -22px;
      margin-bottom: 25px;
    }
    
    ol li.hidden{
      visibility:hidden;
      position:absolute;
      left:-999vw;
    }
    
    ol li:before {
        content: "0" counter(items)". ";
        color:green;
        display:inline-block;
        width:22px;
        font-size:14px;
    }
    
    ol li:nth-child(n+10):before {
        content: "" counter(items)". ";
    }
    
    
    1. Item 4
    2. Item 5
    3. Item 6
    4. Item 7
    5. Item 8
    6. Item 9
    7. Item 10

提交回复
热议问题