html 去除max-height,HTML Style maxHeight用法及代码示例
maxHeight屬性設置/返回元素的最大高度。 maxHeight屬性僅影響block-level元素,絕對或固定位置元素。
用法:
它用于設置maxHeight屬性:
object.style.maxHeight = "none|length|%|initial|inherit"
它用于返回maxHeight屬性:object.style.maxHeight
示例1:使用長度單位設置元素的最大高度。
DOM Style maxHeight Property#Geek1 {
color:white;
height:100px;
background:green;
}
GeeksForGeeks
DOM Style maxHeight Property
Click to change
function mygeeks() {
// Set maximum height using
// Using length unit.
document.getElementById(
"Geek1").style.maxHeight =
"40px";
}
輸出
在單擊按鈕之前:
單擊按鈕后:
示例2:使用“%”設置最大高度
DOM Style maxHeight Property#Geek1 {
color:white;
height:50%;
background:green;
}
#Geek_Center {
background:yellow;
width:400px;
height:150px;
margin-left:150px;
text-align:center;
}
GeeksForGeeks
DOM Style maxHeight Property
Click to change
function mygeeks() {
//set maximum height.
document.getElementById(
"Geek1").style.maxHeight = "35%";
}
輸出
在單擊按鈕之前:
單擊按鈕后:
支持的瀏覽器:HTML支持的瀏覽器| DOM樣式maxHeight屬性>列出如下:
谷歌瀏覽器
Edge
火狐瀏覽器
Opera
Safari
總結
以上是生活随笔為你收集整理的html 去除max-height,HTML Style maxHeight用法及代码示例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 疲劳指数正常范围
- 下一篇: 2017年html5行业报告,云适配发布