HTML height 属性
htmlweb developmentfront end technology更新于 2025/11/28 13:00:17
HTML height 属性用于声明元素的高度(以像素为单位)。
注意 − 自 HTML5 起,已移除以 ‘%’ 指定高度的支持。
以下 HTML 元素具有 height 属性 −
- canvas
- embed
- iframe
- img
- input
- object
- video
让我们看一个 Video height 属性的示例 −
示例
<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Video height</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-height</legend>
<video id="wordPressIntro" width="320" height="50" controls><source src=" http://www.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 wordPressIntro = document.getElementById("wordPressIntro");
function getTrackDetails() {
wordPressIntro.height += 50;
divDisplay.textContent = 'Video height: '+wordPressIntro.height;
}
</script>
</body>
</html>
这将产生以下输出 −
1) 点击"视频不可见"按钮前 −

2) 点击"视频不可见"按钮三次 −

相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

