HTML DOM中的minHeight属性用于设置或返回元素的最小高度。此属性仅影响block-level元素,绝对或固定位置元素。
用法:
它返回minHeight属性。object.style.minHeight
它用于设置minHeight属性。object.style.minHeight = "length|%|initial|inherit"
属性值:
值
描述
length
以长度单位定义长度。
%
定义与父元素相比的长度百分比
initial
设置默认的初始值。
inherit
从父元素继承属性。
返回值:它返回元素的最小高度。
范例1:
DOM Style minHeight Property
#Geek1 {
color:white;
width:50%;
background:green;
}
GeeksForGeeks
DOM Style minHeight Property
Click to change
function geeks() {
document.getElementById("Geek1").style.minHeight
= "150px";
}
输出:
在单击按钮之前:
单击按钮后:
范例2:
DOM Style minHeight Property
#Geek1 {
color:white;
width:50%;
background:green;
}
#Geek_Center {
background:yellow;
height:200px;
}
GeeksForGeeks
DOM Style minHeight Property
Click to change
function geeks() {
document.getElementById("Geek1").style.minHeight
= "50%";
}
输出:
在单击按钮之前:
单击按钮后:
支持的浏览器:下面列出了DOM Style minHeight属性支持的浏览器:
谷歌浏览器
IE浏览器
火狐浏览器
Opera
Safari