I'm struggling with a seemingly simple problem that I just can't seem to solve. I'm trying to get the height of my div element, but for some reason it keeps returning 0. Even when I inspect the element in Chrome, it shows me a height. Here's the code:
HTML
<div id="signup">
<div class="panel">
</div>
</div>
CSS:
.panel
{
width: 90%;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-ms-border-radius: 10px;
-o-border-radius: 10px;
border-radius: 10px;
background: #0071bc;
padding: 1em;
border: 0.3em solid;
border-color: #073b73;
color: #ffffff;
position: relative;
left:0;
right: 0;
margin: auto;
}
JQuery:
alert($("#signup .panel").outerHeight());
alert($("#signup .panel").height());
I've tried using these lines within both document ready and window load functions but keep getting a height of 0. What I have noticed is that if I specify a fixed height in the CSS like height:361px;
or height:40%;
, then I do get a value. However, I need the panel's height to adjust dynamically based on its contents. How do I retrieve this height once it's rendered? I'm truly stuck here, any help would be greatly appreciated.