スタイルmaxHeightプロパティ
例
<div>要素の最大の高さを設定します。
document.getElementById("myDIV").style.maxHeight = "15px";
定義と使用法
maxHeightプロパティは、要素の最大の高さを設定または返します。
maxHeightプロパティは、ブロックレベルの要素、または絶対位置または固定位置の要素にのみ影響します。
注:要素の高さは、maxHeightプロパティで指定された値を超えることはできません。
ヒント:要素の最小の高さを設定または返すには、minHeightプロパティを使用します。
ブラウザのサポート
Property | |||||
---|---|---|---|---|---|
maxHeight | Yes | Yes | Yes | Yes | Yes |
構文
maxHeightプロパティを返します。
object.style.maxHeight
maxHeightプロパティを設定します。
object.style.maxHeight = "none|length|%|initial|inherit"
プロパティ値
Value | Description |
---|---|
none | No limit on the height of the element. This is default |
length | Defines the maximum height in length units |
% | Defines the maximum height in % of the parent element |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
技術的な詳細
デフォルト値: | なし |
---|---|
戻り値: | 要素の最大の高さを表す文字列 |
CSSバージョン | CSS2 |
その他の例
例
<div>要素の最大の高さを返します。
alert(document.getElementById("myDIV").style.maxHeight);
関連ページ
CSSチュートリアル:CSSディメンション
CSSリファレンス:max-heightプロパティ
❮スタイルオブジェクト