:current
:current CSS 偽類選擇器是一個時間維度偽類,表示當前正在顯示的一個元素或其祖先元素。例如,這個偽類可以用來表示透過 WebVTT 顯示字幕的影片。
css
:current(p, span) {
background-color: yellow;
}
語法
css
:current {
/* ... */
}
:current(<compound-selector-list>) {
/* ... */
}
示例
CSS
css
:current(p, span) {
background-color: yellow;
}
HTML
html
<video controls preload="metadata">
<source src="video.mp4" type="video/mp4" />
<source src="video.webm" type="video/webm" />
<track
label="English"
kind="subtitles"
srclang="en"
src="subtitles.vtt"
default />
</video>
WebVTT
WEBVTT FILE 1 00:00:03.500 --> 00:00:05.000 This is the first caption 2 00:00:06.000 --> 00:00:09.000 This is the second caption 3 00:00:11.000 --> 00:00:19.000 This is the third caption
規範
| 規範 |
|---|
| 選擇器 Level 4 # the-current-pseudo |
瀏覽器相容性
目前沒有瀏覽器支援此功能。