2011-04-11 100 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> 

如果您根本没有指定尺寸,则视频将以其原始尺寸显示。