Considering the following HTML:
<div style="line-height: 20px;">
<p style="margin: 0;">Paragraph 1</p>
<p style="margin: 0;">Paragraph 2</p>
<p style="margin: 0;">Paragraph 3</p>
</div>
If I change the line-height
via Javascript, is it guaranteed that I'll be able to know the new height from the div
right away?
Or is it safer to use requestAnimationFrame
to make sure the styles are applied and calculated?
const div = document.querySelector("div");
console.log(div.clientHeight); // 60
div.style.lineHeight = "40px";
console.log(div.clientHeight); // 120?
<div style="line-height: 20px;">
<p style="margin: 0;">Paragraph 1</p>
<p style="margin: 0;">Paragraph 2</p>
<p style="margin: 0;">Paragraph 3</p>
</div>