Googled - did not help, googled in English - did not help either, came to the good old Stackoverflow. So, immediately to the point. The layout structure is as follows:
<div class="header"> <div> <h1>Hello world</h1> </div> <div> <img style="height: 100%"> </div> </div> I'm trying to get the height .header most ordinary
console.log( $('.header').height() ); And here is the most interesting thing: if I insert this function into the usual <script> inside the $(document).ready(function () {}); , then the value greater than real is displayed in the console. If I enter the above code into the browser console after the page has loaded, it gives a valid one.
As a result of a long googling, I found out that this is a feature caused by the line-height , which, as I understand it, is calculated after the DOM is ready. And the fact is that my font is connected, everything works properly on the default Helvetik. The task , as I understand it , is to call this function after rendering line-height . And to confirm the source of the problem, I decided to equate line-height to 0 , and voila - everything also works. Help. I hope lucidly described the problem.
.headerblock, and not in theline-height. Try to give it a fixed height in pixels via theheightattribute, or simply delete it. - neluzhin$(document).ready(function () {/* ... */});, and inwindow.onload = function() { /* ... */ };- only works when all assets, including your font, are loaded. - neluzhin