I desprately need to set this DIV "two" height to be calculated as 100% - (minus) another DIV height (div "one"). The thing is, the height of that another DIV (div "one") is dynamic already.
So:
<body>
<div id="one"></div>
<div id="two"></div>
</body>
div { position: relative; }
body { height: 100vh; }
I tried things like these, but that doesn't work:
$(document).ready(exe);
$(window).resize(exe);
function exe(){
var topHeight = $('#one').outerHeight(true);
$('#two').css("height", "calc(100% - topHeight)")
}
or
$(document).ready(exe);
$(window).resize(exe);
function exe(){
var topHeight = $('#one').outerHeight(true);
var topHeightCalc = '100%' - topHeight;
$('#two').css("height", topHeightCalc)
}
You need to correct string concatenation in the CSS value to
"calc(100% - "+ topHeight +"px)"
Hey friend you can also achieve what you want without using the calc() function.
This gets height of the window and deduct height of the div
#one
from that and apply that height to div#two
.A more extravagant way of doing this, if browser compatibility is not an issue, is to use display: table. This way you can achieve your desired effect without using any JS.