這裏是我的示例代碼獲取有關父DIV高度和家長的高度depand DIV高度depand對文件的高度
<div id="one">
height based on screen
<div id="two">
height based on id="one"
<div>
height based on id="two"
</div>
</div>"
</div>
這裏是我的示例代碼獲取有關父DIV高度和家長的高度depand DIV高度depand對文件的高度
<div id="one">
height based on screen
<div id="two">
height based on id="one"
<div>
height based on id="two"
</div>
</div>"
</div>
html, body { height:100%; }
#one { height:some%; }
#two { height:some%; }
CSS - 沒有需要在這裏(除非你想以後更改高度)JS。
只需使用$(this).parent().height();
爲每div
設置高度和寬度%。它將採用父div的高度和寬度。
應該在哪裏調用? – Uooo