How do you get the rendered height of an element?

前端 未结 18 2706
情书的邮戳
情书的邮戳 2020-11-22 03:11

How do you get the rendered height of an element?

Let\'s say you have a

element with some content inside. This content inside is going to st
18条回答
  •  梦谈多话
    2020-11-22 03:36

    I use this to get the height of an element (returns float):

    document.getElementById('someDiv').getBoundingClientRect().height
    

    It also works when you use the virtual DOM. I use it in Vue like this:

    this.$refs['some-ref'].getBoundingClientRect().height
    

提交回复
热议问题