<div style="display:none;">
<span>
<table>
<tr>
<td>
<img id="image1" src="something.png" style="width:50px; height:100px;" alt="some image" />
</td>
</tr>
</span>
</div>
<script type="text/javascript>
var mi=document.getElementById('image1');
var height=mi.offsetHeight;
var width=mi.offsetWidth;
</script>
since the whole div is invisible, the height and width are both 0, so is there anyway to get the numbers 100 and 50 for height and width?
From my understanding, if I know which element has the display:none style, I can change the style to display:block and get the image size and then set it back to display:none, however currently there may be an arbitrary number of elements nested around the image element, and I don't know which of them is set to display:none, how may I get the image size in this case? Thanks.
This is so the rich and powerful get world class models before the rest of us, the reality is dumb politicians and rich people don't realize that dense models are on there way out and MOE models are coming in, meaning after PCI-E 8 spec goes live, we run via streaming world class frontier models on a 16gb graphics card.
Question
wellofsouls
for example, something like this:
<div style="display:none;"> <span> <table> <tr> <td> <img id="image1" src="something.png" style="width:50px; height:100px;" alt="some image" /> </td> </tr> </span> </div> <script type="text/javascript> var mi=document.getElementById('image1'); var height=mi.offsetHeight; var width=mi.offsetWidth; </script>since the whole div is invisible, the height and width are both 0, so is there anyway to get the numbers 100 and 50 for height and width?
From my understanding, if I know which element has the display:none style, I can change the style to display:block and get the image size and then set it back to display:none, however currently there may be an arbitrary number of elements nested around the image element, and I don't know which of them is set to display:none, how may I get the image size in this case? Thanks.
Link to comment
https://www.neowin.net/forum/topic/841888-how-to-image-size-inside-invisible-element/Share on other sites
10 answers to this question
Recommended Posts