How to get the height of a DIV considering inner element's margins?

前端 未结 11 3177
日久生厌
日久生厌 2021-02-20 04:20

Consider de following markup:

11条回答
  •  温柔的废话
    2021-02-20 04:45

    you could use jQuery:

    $('#outerElement').height(); // gets the height of the div
    $('#outerElement').outerHeight(); // gets the height of the div including margins and padding
    $('#outerElement').innerHeight(); // gets the height of the div including padding
    

    one of those is bound to work.

提交回复
热议问题