Latest web development tutorials

HTML DOM Style maxHeight property

Style Object Reference Style Objects

Definition and Usage

maxHeight property sets or returns the element's maximum height.

maxHeight properties play a role only in the block-level element or elements of absolute / fixed position.

Note: The height of an element can never be greater than the value specified maxHeight property.

grammar

Setting maxHeight properties:

Object.style.maxHeight="none|length|%|inherit"

Back maxHeight properties:

Object.style.maxHeight

描述
none 默认。元素的高度没有限制。
length 使用 px、cm 等单位定义最大高度。
% 定义最大高度为父元素的百分比。
inherit maxHeight 属性的值从父元素继承。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support maxHeight property.

Note: IE7 and earlier versions do not support the "inherit" value.IE8 only provides! DOCTYPE supported "inherit". IE9 support "inherit".


Examples

Examples

Sets the maximum height of the element:

<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Script>
function displayResult () {
document.getElementById ( "p1") style.maxHeight = "15px".;
}
</ Script>
</ Head>
<Body>

<P style = "background: red;" id = "p1"> This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. </ P>
<Input type = "button" onclick = "displayResult ()" value = "setting the element's maximum height">

</ Body>
</ Html>

try it"


Style Object Reference Style Objects