影片
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
為影片體驗核心指標最佳化影片時,請務必在 <video>
標記上設定 width
和 height
屬性。視情況而定,您可能也需要使用 poster
屬性。
width
和 height
屬性:如要避免版面配置位移,請在 <video>
標記上設定 width
和 height
屬性。如此一來,瀏覽器就能判斷影片的尺寸 (並保留正確的空間大小),不必等待影片下載。
poster
屬性 (選用):poster
屬性會指定影片下載時應顯示的圖片。如果影片是 LCP 元素,LCP 取決於海報圖片轉譯時間,而非整體影片載入的時間。如未指定這項屬性,瀏覽器會等到影片的第一個影格可供使用,再用它做為海報圖片;沒有 poster
屬性的影片目前不會考慮大型內容繪製。
在此範例中,CSS 會使用 CSS 確保影片依照容器調整大小。這不會影響網站體驗指標,但具有實用技巧。
HTML
<video controls width="960" height="540" poster="flower-960-poster.png">
<source src="flower-960.mp4" type="video/mp4">
</video>
CSS
video {
max-width: 100%;
height: auto;
}
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-03-13 (世界標準時間)。
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"缺少我需要的資訊"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"過於複雜/步驟過多"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"過時"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻譯問題"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"示例/程式碼問題"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"容易理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"確實解決了我的問題"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]