contentに合わせて iframe のサイズを変更する必要がありますが、試した高さのプロパティはposition: fixed
.
absolute
およびfixed
クラスを持つ 2 つの要素のみを含むドキュメントを想定します。
body { padding: 0; margin: 0; }
.absolute {
position: absolute;
height: 100px;
}
.fixed {
position: fixed;
height: 200px;
}
html.scrollHeight
0 (Opera/Firefox のビューポートの高さ)html.offsetHeight
0body.scrollHeight
0 (Chrome のビューポートの高さ)body.offsetHeight
0body.outerHeight
0
を追加するとhtml { position: relative; }
、html.scrollHeight
Chrome では 100px になりますが、200px になる値はありません。最初はフロートにも問題がありましたが、に clearfix を追加することで解決しましたbody
。
ここで jsbin を作成しました: http://jsbin.com/ehixiq
実際の高さを取得できない場合、最善の回避策は何ですか? サポートする必要があるのは、Opera、Chrome、および Firefox の最新バージョンだけです。