开发者

Consistent left-aligning of a numerical list

开发者 https://www.devze.com 2023-02-15 14:54 出处:网络
How do you make sure all the content in a numerical list is left aligned to the same spot? You see how when you go from #9 to #10, the numbering gets an extra digit and pushes the content a little bit

How do you make sure all the content in a numerical list is left aligned to the same spot? You see how when you go from #9 to #10, the numbering gets an extra digit and pushes the content a little bit to the right? I can live with #99-to-#100 screwing things up, but I'd like to fix t开发者_StackOverflow中文版his #9-to-#10 issue. Making the numbering go outside makes the content align properly, but then there's no background on the numbering.

Consistent left-aligning of a numerical list

#file ol {
    line-height: 3em;
    font-size: 1.2em;
    color: #999;
}

    #file ol li {
        list-style: decimal inside none;
        padding: 0 0 0 1em;
    }

    #file ol li.alt {
        background: #eee;
    }


The list style needs to be outside for this to happen.

#file ol li {
    list-style: decimal outside none;
    padding: 0 0 0 1em;
}

The only other option, to fix your background issues, would be to use another element inside the LI that you place inline-block with a predefined width and manually increment or to use a table. If your project does not rely on backwards compatability, please let me know as there may be some CSS3 options.

0

精彩评论

暂无评论...
验证码 换一张
取 消