I have a div which contains different amount of text at different moments (determined by what the server decides to send). I want to find the height this div would take if rendered. At the point when I want the height, the div is not being rendered (display:none
). The display is to be set to 'block' later.
I have tried .offsetHeight
and it works well after I set display:block
for the div. However, I want the height at the time wh开发者_JS百科en display is set to 'none'. Any ideas?
You cannot determine the height until it's rendered. So with display: none;
, it won't be possible.
A work around would be to set visibility:hidden;
and change it to visible
when you are done with your resizing
If you position the element absolute and do as RageZ says you can measure it. Then you could set the position back to static.
精彩评论