Vanessa 2025-01-10 12:13:17 +08:00
parent 736fdb2d7e
commit 1ee7848f93

View file

@ -138,8 +138,9 @@ export const lineNumberRender = (block: HTMLElement) => {
const lineNumberTemp = document.createElement("div"); const lineNumberTemp = document.createElement("div");
lineNumberTemp.className = "hljs"; lineNumberTemp.className = "hljs";
// 不能使用 codeElement.clientWidth被忽略小数点导致宽度不一致
lineNumberTemp.setAttribute("style", `padding-left:${codeElement.style.paddingLeft}; lineNumberTemp.setAttribute("style", `padding-left:${codeElement.style.paddingLeft};
width: ${codeElement.clientWidth}px; width: ${codeElement.getBoundingClientRect().width}px;
white-space:${codeElement.style.whiteSpace}; white-space:${codeElement.style.whiteSpace};
word-break:${codeElement.style.wordBreak}; word-break:${codeElement.style.wordBreak};
font-variant-ligatures:${codeElement.style.fontVariantLigatures}; font-variant-ligatures:${codeElement.style.fontVariantLigatures};