💾 Archived View for chirale.org › 2014-09-04_ebbb24458beac9d2d1eba1ddd6c82a32.gmi captured on 2024-08-24 at 23:56:42. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2024-05-12)
-=-=-=-=-=-=-
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