On my web page I have a popup image in a series of nested divs. At the top div I have a title. While the higher resolution of this image is loading, I display an emoji hourglass (⏳) in the title. When completed, I remove the hourglass. When the hourglass is removed, the div with the title text in it gets a little smaller, vertically. How can I have the emoji equal to the size of the text so that it does not make my div any taller?
Here is a code snippet that shows a div with a cyan background color and an emoji. When the button is clicked, the innerHTML is replaced with text without emoji and you can see the vertical size get smaller.
document.getElementById("button").onclick =
() => {document.getElementById("div").innerHTML = "This is some text without emoji"};
div.textWithEmoji {
font-size : medium;
background-color : cyan;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Emoji Size Test</title>
</head>
<body>
<h1>Emoji Size Test</h1>
<div class="textWithEmoji" id="div">
This is some text with emoji ⏳
</div>
<br>
<button id="button" type="button">Remove Emoji</button>
</body>
</html>
I don't want to force the div height to a specific value as the font-size is a variable in my page.
I have tried setting the size of the emoji to 75% and that works on Chrome and iOS but there is no guarantee that that will work on every platform.
Any ideas how I can get this to do what I want?
Thanks,
Mike