:past

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

:past CSS 偽類選擇器是一個時間維度偽類,它匹配所有完全出現在匹配 :current 的元素之前的元素。例如,在透過 WebVTT 顯示字幕的影片中。

css
:past(p, span) {
  display: none;
}

語法

css
:past {
  /* ... */
}

示例

CSS

css
:past(p, span) {
  display: none;
}

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-past-pseudo

瀏覽器相容性

另見