question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Line height rendering issue on Chromium 94+ and higher, and Firefox.

See original GitHub issue

Prerequisites

Describe the issue

Hey guys,

Not sure if you were aware, but starting with Chromium 94.0.4584 and higher, the Chromium got a fix related to the way they were calculating line-heights: https://chromium-review.googlesource.com/c/chromium/src/+/2824938

This change affects all Blink based browsers (Chrome, Edge, Opera, etc), but also Firefox.

Safari is NOT affected by this.

So what happens in recent versions, they’re including the subpixels of line-height (when a line height has subpixels) when calculating the container’s total height.

This comes with an unexpected behavior, which breaks any pixel perfect designs when using classes that have a line-height set to a ratio based unit, unless the line-height value calculated happens to be a number with no decimals.

I’ve created 2 simple tests that which can be seen at:

16px base font on the Browser’s settings: https://codepen.io/pricop/pen/ExwWZJZ 17px base font on the Browser’s settings: test: https://codepen.io/pricop/pen/bGoqgZJ

I’ve took screenshots of each of them, and measured what the browser has rendered, and the results are as follows:

16px results: https://i.imgur.com/swLGjh4.png 17px results: https://i.imgur.com/h3eOZZi.png

The culprit in this particular case, is the “small” helper class that Boostrap includes. This class has the font-size set to 80%. When a browser has the default font size set to 16px (which is what the vast majority of browsers have), the line-height in newer versions will not be floored, as in previous versions, so rather than the line-height being calculated at 19px, it is now calculated at 19.2px, which causes the issues presented in the results.

The fix would be have the line-height for classes that are using ratio based values (such as small, display-*, etc. classes) to a value with no decimals when the browser’s calculates it.

This issue can be followed at: https://bugs.chromium.org/p/chromium/issues/detail?id=1278566 - but by the looks of it, this is something that’s here to stay, and I’ve been instructed to adjust my CSS instead.

Reduced test cases

https://codepen.io/pricop/pen/ExwWZJZ https://codepen.io/pricop/pen/bGoqgZJ

What operating system(s) are you seeing the problem on?

Windows

What browser(s) are you seeing the problem on?

Chrome, Firefox, Microsoft Edge, Opera

What version of Bootstrap are you using?

4.0.0 but it affects all the others.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
pricopcommented, Dec 22, 2021

Chrome BS4 16px chrome BS4 17px

0reactions
pricopcommented, Apr 14, 2022

Done.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why line-height in Firefox and Chrome is different?
In Chrome all looks fine, but in Firefox height of span elements bigger than height of their ancestor. If I adjust vertical padding...
Read more >
1278566 - Chrome 96 and higher render issue.
Chrome 95, Safari and Firefox would render all rows the same height. Chrome 95, and Safari at 67px, while Firefox would render the...
Read more >
CSS Property 'line-height' has no effects on input text fields
Just open the web page linked here and see the example Actual Results: The text into the text field doesn't have the line-height...
Read more >
document - CSS: Cascading Style Sheets - MDN Web Docs
Browser compatibility · Chrome · Edge · Firefox · Opera · Safari · Chrome Android · Firefox for Android · Opera Android ...
Read more >
width - CSS: Cascading Style Sheets - MDN Web Docs
Ensure that elements set with a width aren't truncated and/or don't obscure other content when the page is zoomed to increase text size....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found