Skip to content

ol label misalign due to non-monospace font #5096

@BEWINDOWEB

Description

@BEWINDOWEB

Is your feature request related to a problem? Please describe.

default font is non-monospace font
Image

Describe the solution you'd like

support monospace font when using ol, like doubao豆包 AI fixed:

Image Image
.vp-doc ol {
    list-style: none;
    counter-reset: order-num;
    padding-left: 0;
    margin: 0;
}

.vp-doc ol li {
    counter-increment: order-num;
    padding-left: 1.75em; /* 给序号预留空间 */
    /* 这里不设置font-family,让内容继承页面原始字体 */
}

/* 仅序号伪元素使用等宽字体 */
.vp-doc ol li::before {
    content: counter(order-num) ".";
    width: 1.25em;
    text-align: right;
    position: absolute;
    left: 0;
    /* 只在序号这里用等宽字体 */
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: inherit; /* 继承列表项字号,保持视觉统一 */
}
Image Image

但是用伪元素这种解决方案也是有问题,比如:

1) 测试机配置

|配置参数|值|
|---|---|
|Vender ID|Genuine Intel|
|CPU Family|6|
|Model|45|
|Model Name|Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz|
|核心数|12|
|内存大小|132137288KB(约126GB)|

2) 测试场景:xxxxx

这种情况,2就会被渲染为1,因为间隔了一个表格,会重新计数。

期待前端大佬有好的解决方法。

Describe alternatives you've considered

No response

Additional context

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    themeRelated to the theme

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions