If you have an html document that goes like this:
<body>
<div id="top"></div>
<div id="rest"></div>
</body>
and I give the "top" div a height of 40px, is there a way to give "rest" div the rest of the height of the body in css. I know it's possible in Javascript like this
function derest(){
var bodyheight = window.getComputedStyle(document.getElementsByTagName('body')[0], null).height;
bodyheight = bodyheight.substring(0, bodyheight.length - 2);
var topheight = window.getComputedStyle(document.getElementById('top'), null).height;
topheight = topheight.substring(0, topheight.length - 2);
restheight = bodyheight - topheight;
document.getElementById("rest").style.height = restheight;
}
but this takes a lot of time, so is there a better way to do this?