Full height of a html element (div) including border, padding and margin?

后端 未结 10 1728
悲&欢浪女
悲&欢浪女 2020-12-01 11:42

I need the full height of a div, I\'m currently using

document.getElementById(\'measureTool\').offsetHeight

offsetHeig

10条回答
  •  隐瞒了意图╮
    2020-12-01 12:17

    The earlier solutions are probably ideal. In search of an easy way, I came up with something like that. This wraps the target in a div. The height of the div is already calculated and rounded.

    something info ex

    and in JavaScript:

    var height = document.querySelector(".target").parentElement.offsetHeight;
    

提交回复
热议问题