Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

HTML <video> width 属性

❮ HTML <video> 标签

示例

一个具有指定宽度和高度的视频播放器

<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  您的浏览器不支持 video 标签。
</video>
自己尝试 »

定义和用法

width 属性指定视频播放器的宽度,以像素为单位。

提示: 始终为视频指定 height width 属性。如果设置了这些属性,则在加载页面时会预留视频所需的空間。但是,如果没有这些属性,浏览器将不知道视频的大小,也无法为其预留适当的空間。效果将是在加载过程中页面布局会发生变化(在视频加载时)。

注意: 不要使用 height width 属性调整视频大小!使用这些属性缩小大型视频会迫使用户下载原始视频(即使它在页面上看起来很小)。调整视频大小的正确方法是在网页上使用之前,使用程序对其进行调整。


浏览器支持

属性
width 4.0 9.0 3.5 3.1 11.5

语法

<video width="像素">

属性值

描述
像素 视频的宽度,以像素为单位(例如 width="100")

❮ HTML <video> 标签
×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.