开发者

Javascript: Calculate height of DIV minus pixels

I'm currently looking for a javascript to do a math calculation for me. I'm looking for something that will read the height of an entire window (not screen size), minus 100px from that value, and then output in to, lets say, a style value. Is something like this possible?

开发者_如何学PythonThanks in advance!


To calculate the height of a div, you can use the property innerHeight, something like:

var height = document.getElementById('somediv').innerHeight;

Then, you can do the calculations you need on this variable, and use later in something like:

document.getElementById('otherdiv').style.height = height + 'px';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜