Skip to content

Commit 46cf1e6

Browse files
committed
feat: add CSS for inline line numbers in code blocks
1 parent 8b18657 commit 46cf1e6

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

docs/stylesheets/extra.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
11
/* 自定义样式 */
22

33
/* 可在此处添加全局样式覆盖 */
4+
5+
/* 代码块行号显示 (pymdownx-inline 模式) */
6+
code .hll { display: block; }
7+
code [id^="__span"] {
8+
display: inline;
9+
}
10+
11+
/* 行号列 */
12+
.highlight [id^="__span"]::before {
13+
counter-increment: linenums;
14+
content: counter(linenums);
15+
display: inline-block;
16+
min-width: 2.5em;
17+
padding-right: 0.8em;
18+
margin-right: 0.5em;
19+
text-align: right;
20+
color: var(--md-default-fg-color--light);
21+
border-right: 1px solid var(--md-default-fg-color--lighter);
22+
user-select: none;
23+
-webkit-user-select: none;
24+
}
25+
26+
.highlight pre {
27+
counter-reset: linenums;
28+
}
29+
30+
/* 行号高亮时的样式 */
31+
.highlight [id^="__span"]:target {
32+
background-color: var(--md-code-hl-color);
33+
}

0 commit comments

Comments
 (0)