Compartilhar via


maxHeight property

Sets or retrieves the maximum height for an element.

 

Syntax

Integer value = object.put_maxHeight(Variant v);Integer value = object.get_maxHeight(Variant* sMaxHeight);

Property values

Type: VARIANT

The maximum height for an element.

length (length)

Floating-point number followed by an absolute units designator (cm, mm, in, pt, or pc) or a relative units designator (em, ex, or px). For more information about the supported length units, see CSS Values and Units Reference.

percentage (percentage)

Integer followed by a % that specifies a percentage of the containing block height to use as the maximum height of the element. If the height of the containing block is not explicitly set, then the element has no maximum height and the IHTMLStyle5::maxHeight property is interpreted as 0%. For more information on containing blocks and how their heights are computed, see the Cascading Style Sheets, Level 2.1 (CSS2.1) specification.

String format

<length> | <percentage>

CSS information

Applies To All elements
Media visual
Inherited no
Initial Value none

Standards information

Remarks

IHTMLStyle5::maxHeight was introduced in Windows Internet Explorer 7.

The IHTMLStyle4::minHeight/IHTMLStyle5::maxHeight attributes apply to floating and absolutely positioned block and inline-block elements, as well as some intrinsic controls. They do not apply to non-replaced inline elements, such as table columns and row/column groups. (A "replaced" element has intrinsic dimensions, such as an img or textArea.)

This property is enabled only under the strict !DOCTYPE.

Examples

The following example shows how the IHTMLStyle5::maxHeight and IHTMLStyle4::minHeight properties affect the layout of a div element.

body {
   background-color: #E3E3E3;
}
#one {
   background-color: #FFF;
   width: 200px;
   max-height: 100px;
}
#two {
   background-color: #FFF;
   width: 200px;
   min-height: 300px
}

The first div will never grow more than 100px in height because IHTMLStyle5::maxHeight is set to 100px. The content does not fit in the div, so it continues beyond it.

The height of the second div is always at least 300px because IHTMLStyle4::minHeight is set to 300px. In this example, the content does not fill the div.

<div id="one">
   <h3>max-height: 100px;</h3>
   Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</div>
<div id="two" >
   <h3>min-height: 300px;</h3>
   Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</div>

You can see the result below.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows 2000 Server

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll

See also

Cascading Style Sheet Compatibility in Internet Explorer 7