HTML DOM 视频 width 属性
HTML DOM Video width 属性返回/设置与媒体宽度(以像素为单位)相对应的数字。
语法
以下是语法 −
返回以数字(px)表示的宽度
mediaObject.width
将宽度设置为数字(px)
mediaObject.width = number
让我们来看一个Video width 属性的示例 −
示例
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Video width</title>
<style>
* {
padding: 2px;
margin:5px;
}
form {
width:70%;
margin: 0 auto;
text-align: center;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>HTML-DOM-Video-width</legend>
<video id="demo" height="200" width="170" controls><source
src="https://tutorialspoint.com/html5/foo.mp4" type="video/mp4"></video><br>
<input type="button" onclick="getTrackDetails()" value="Video Not Visible">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var demo = document.getElementById("demo");
function getTrackDetails() {
demo.width += 50;
divDisplay.textContent = 'Video width: '+demo.width;
}
</script>
</body>
</html>输出
单击“视频不可见”按钮之前 −

单击“视频不可见”按钮 3 次 −

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP