跳到主要內容

數字最大精度

限制數字中允許的小數位數。

a { top: 3.245634px; }
/** ↑
* This decimal place */

message 次要選項 可以接受此規則的引數。

選項

int:允許的最大小數位數。

例如,使用 2

以下模式被視為問題

a { top: 3.245px; }
a { top: 3.245634px; }
@media (min-width: 3.234em) {}

以下模式不是問題

a { top: 3.24px; }
@media (min-width: 3.23em) {}

選用次要選項

ignoreProperties: ["/regex/", /regex/, "string"]

忽略指定屬性的數字精度。

例如,使用 0

給定

["transition"]

以下模式被視為問題

a { top: 10.5px; }

以下模式不是問題

a { transition: all 4.5s ease; }

ignoreUnits: ["/regex/", /regex/, "string"]

忽略具有指定單位的數值的精度。

例如,使用 2

給定

["/^my-/", "%"]

以下模式被視為問題

a { top: 3.245px; }
a { top: 3.245634px; }
@media (min-width: 3.234em) {}

以下模式不是問題

a { top: 3.245%; }
@media (min-width: 3.23em) {}
a {
width: 10.5432%;
}
a { top: 3.245my-unit; }
a {
width: 10.989my-other-unit;
}

insideFunctions: {"/regex/": int, /regex/: int, "string": int}

insideFunctions 選項可以變更指定函式的主要選項值。

例如,使用 2

給定

{"/^(oklch|oklab|lch|lab)$/", 4}

以下模式被視為問題

a { color: rgb(127.333 0 0); }
a { color: rgb(calc(127.333 / 3) 0 0); }

以下模式不是問題

a { color: oklch(0.333 0 0); }
a { color: lab(0.3333 0 0); }
a { color: oklab(calc(127.333 / 3) 0 0); }