💾 Archived View for chirale.org › 2014-09-04_f70b0fe7dec8e195bf1134e889904425.gmi captured on 2024-05-12 at 15:23:15. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
Recently we’ve nice fonts on web pages like Google Fonts and other web fonts. Take this case, you have to set two divs to the same height. One (div.funny) has some text with Google Fonts, the other is empty.
On Chrome console you type something like:
jQuery(".very", ".myview").height(function () { jQuery(this).height(jQuery(this).parent(".myview").find('.funny').height()); });
Div.very and div.funny are now at the same height.
Now if you try to do the same on jquery document ready you got elements with different height. Why?
Because the calculation happens on document ready but before fonts are loaded. The solution is to wrap the code on $(window).load().
$(window).load(function () { $(".very", ".myview").height(function () { $(this).height($(this).parent(".myview").find('.funny').height()); }); });
Now .very and .funny are at the same height.
Calculate Container’s Height After The Font File Loads