Suppose there is a div1 with div2 and div3 inside. div2 has been laid out with a fixed height. How to make div3 cover the remaining height? Please attach your self-written code, thank you!
Seeking popularity.
function getdomheight(dom){ //Get the height of a dom
return dom.offsetHeight;
}
var div1 = document .getElementById('div1's id');
var div2 = document.getElementById('div2's id');
var div3 = document.getElementById('div3's id');
div3.style.height = getdomheight(div1) - getdomheight(div2) 'px';
is subtraction
function getdomheight(dom){ //Get the height of a dom
return dom.offsetHeight;
}
var div1 = document.getElementById('div1's id');
var div2 = document.getElementById('div2's id') ;
var div3 = document.getElementById('div3's id');
div3.style.height = getdomheight(div1) - getdomheight(div2) 'px';
That's it Subtraction
function getdomheight(dom){ //Get the height of a dom
return dom.offsetHeight;
}
var div1 = document.getElementById('div1's id');
var div2 = document.getElementById('div2's id');
var div3 = document.getElementById('div3's id') ');
div3.style.height = getdomheight(div1) - getdomheight(div2) 'px';
is subtraction
function getdomheight(dom){ //Get a dom Height
return dom.offsetHeight;
}
var div1 = document.getElementById('div1's id');
var div2 = document.getElementById('div2's id') ');
var div3 = document.getElementById('div3's id');
div3.style.height = getdomheight(div1) - getdomheight(div2) 'px';
It’s subtraction
Use jQuery to get height subtraction, which has good compatibility;
In the example below, the border is only used to check whether the desired effect is achieved. If there is a border in actual application, the border needs to be taken into account when subtracting