How do you find the dimensions of a “display: none” element?

后端 未结 6 844
轻奢々
轻奢々 2021-02-13 18:58

I have some child elements inside a div that gets the CSS display: none applied to it and I want to find out what the child element dimensions are. How can I do thi

6条回答
  •  伪装坚强ぢ
    2021-02-13 19:41

    You can add this :

    var wmd1Style = window.getComputedStyle(wmd1);
    o.innerHTML = 'wmd1: "' + parseInt(wmd1Style['width'], 10) + '", "' + parseInt(wmd1Style['height'], 10) + '", wmd2: "' + wmd2.clientWidth + '", "' + wmd2.clientHeight + '"';
    

提交回复
热议问题