2011-04-11 91 views

回答

2

是的,HTML5視頻同時具備。我認爲它按照最小的價值來衡量。例如,如果你說「width = '20%'height = '50%'」,它會將所有內容都縮放到20%。

在這裏嘗試W3school video tag。如果您想使用像素,請在末尾放置'px',百分比使用'%'。

+4

避免W3schools,他們充滿錯誤信息:http://w3fools.com/。請嘗試使用Mozilla開發人員網絡(https://developer.mozilla.org/)或HTML5介紹性網站(如HTML5 Doctor(http://htmldoctor.com))。 – RobW 2012-05-02 17:45:52

+0

這不是有效的HTML5。 Orio的答案是正確的。 – 2017-06-15 23:12:00

4

基於W3C specificationwidthheight以CSS像素而不是百分比定義視頻大小。所以設置一個%值是行不通的。

<!-- No `px` at the end of the value like CSS --> 
<video width="980" height="560" ... > ... </video> 

它總是最好的,這樣的網頁並不需要回流到指定heightwidth屬性。如果像素值不適合您,請不要指定視頻尺寸屬性,而應使用樣式屬性以百分比值指定heightwidth

<!-- Let's supposed you want the video to adjust to the size of its parent element --> 
<video style="outline:none; width:100%; height:100%;" ... > ... </video> 

如果您根本沒有指定尺寸,則視頻將以其原始尺寸顯示。