: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 |
浏览器兼容性
目前没有浏览器支持此功能。