VTTCue:positionAlign 屬性
VTTCue 介面的 positionAlign 屬性用於確定 VTTCue.position 的錨定位置。
值
包含以下值之一的字串:
"line-left"-
行左對齊。
"center"-
居中對齊。
"line-right"-
行右對齊。
"auto"-
自動對齊,取決於 cue 的文字對齊方式,解釋如下:
- line-left: 如果文字對齊方式為 left,或者 cue 使用 LTR 語言且文字對齊方式為 start,或者 cue 使用 RTL 語言且文字對齊方式為 end。
- line-right: 如果文字對齊方式為 right,或者 cue 使用 RTL 語言且文字對齊方式為 start,或者 cue 使用 LTR 語言且文字對齊方式為 end。
- center: 如果沒有設定文字對齊位置。
示例
在下面的示例中,首先建立一個新的 VTTCue,然後將 positionAlign 的值設定為 "line-right"。最後將該值列印到控制檯。
js
let video = document.querySelector("video");
let track = video.addTextTrack("captions", "Captions", "en");
track.mode = "showing";
let cue = new VTTCue(0, 0.9, "Hildy!");
cue.positionAlign = "line-right";
console.log(cue.positionAlign);
track.addCue(cue);
規範
| 規範 |
|---|
| WebVTT:網頁影片文字軌道格式 # dom-vttcue-positionalign |
瀏覽器相容性
載入中…