::-webkit-meter-even-less-good-value
非標準:此特性未標準化。我們不建議在生產環境中使用非標準特性,因為它們瀏覽器支援有限,並且可能會更改或被移除。但是,在沒有標準選項的特定情況下,它們可以是合適的替代方案。
::-webkit-meter-even-less-good-value 樣式在 <meter> 元素的 value 和 optimum 屬性落在 low-high 範圍之外,但處於相反區域時生效。為了說明這一點,它在 value < low < high < optimum 或 value > high > low > optimum 時適用。
預設顏色為紅色。
語法
css
::-webkit-meter-even-less-good-value {
/* ... */
}
示例
HTML
html
Normal:
<meter min="0" max="10" low="3" high="7" optimum="8" value="2">
Score 2/10
</meter>
<br />
Styled:
<meter id="styled" min="0" max="10" low="3" high="7" optimum="8" value="2">
Score 2/10
</meter>
CSS
css
body {
font-family: monospace;
}
.safari meter {
/* Reset the default appearance for Safari only */
/* .safari class is added via JavaScript */
-webkit-appearance: none;
}
#styled::-webkit-meter-even-less-good-value {
background: linear-gradient(
to bottom,
#ff7777,
#990000 45%,
#990000 55%,
#ff7777
);
height: 100%;
box-sizing: border-box;
}
JavaScript
js
// Safari requires <meter> elements to have an `appearance` of `none` for custom styling
// using `::-webkit-meter-*` selectors, but `appearance: none` breaks rendering on Chrome.
// Therefore, we must check if the browser is Safari-based.
const is_safari =
navigator.userAgent.includes("AppleWebKit/") &&
!navigator.userAgent.includes("Chrome/");
if (is_safari) {
document.body.classList.add("safari");
}
結果
規範
不屬於任何標準。
瀏覽器相容性
載入中…
另見
WebKit/Blink 用於樣式化 <meter> 元素其他部分的偽元素如下: