Is it possible to retrieve the dimensions of child elements inside a div that has been hidden with CSS property display: none
? If so, how can this be achieved?
Check out the Fiddle Demo here
var o = document.getElementById('output');
var wmd1 = document.getElementById('whats-my-dims1');
var wmd2 = document.getElementById('whats-my-dims2');
o.innerHTML = 'wmd1: "' + wmd1.clientWidth + '", "' + wmd1.clientHeight + '", wmd2: "' + wmd2.clientWidth + '", "' + wmd2.clientHeight + '"';
#some-hidden-div{
display: none;
}
.whats-my-dims{
width: 69px;
height: 42px;
background-color: #f00;
}
<div id='output'>Processing... :p</div>
<div id='some-hidden-div'>
<div class='whats-my-dims' id='whats-my-dims1'></div>
</div>
<div class='whats-my-dims' id='whats-my-dims2'></div>
I am looking for a solution using pure JavaScript only (no jQuery).
The restriction is not to modify parameters such as top, left, right, bottom, transform, translate, etc. This is necessary as the functionality will be integrated into an animated sprite sheet custom component with child elements.