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

后端 未结 6 2059
眼角桃花
眼角桃花 2021-02-13 19:04

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:36

    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 + '"';
    

提交回复
热议问题