如何使用JavaScript设置元素的最小高度?
使用JavaScript中的minHeight属性设置最大高度。您可以尝试运行以下代码以使用JavaScript设置元素的最小高度-
示例
<!DOCTYPE html>
<html>
<head>
<style>
#box {
width: 300px;
background-color: gray;
overflow: auto;
}
</style>
</head>
<body>
<p>Click below to set Minimum height.</p>
<button type="button" onclick="display()">Min Height</button>
<div id="box">
<p>This is a div. This is a div. This is a div.</p>
<p>This is a div. This is a div. This is a div.</p>
<p>This is a div. This is a div. This is a div.</p>
<p>This is a div. This is a div. This is a div.</p>
<p>This is a div. This is a div. This is a div.</p>
</div>
<br>
<script>
function display() {
document.getElementById("box").style.minHeight = "400px";
}
</script>
</body>
</html>热门推荐
10 心媳妇生日祝福语简短
11 回复姐姐生日祝福语简短
12 岁月有芬芳祝福语简短
13 平安果祝福语简短霸气
14 送祝福语给别人简短
15 画室揭牌仪式祝福语简短
16 送别的祝福语朋友简短
17 对战友的祝福语简短
18 公司生日祝福语员工简短