normalize.css icon indicating copy to clipboard operation
normalize.css copied to clipboard

Line-height:1.15 results in v scroll bar (flexbox)

Open kayomarz opened this issue 3 years ago • 1 comments

html {line-height:1.15} used by normalize leads to an unexpected vertical scroll bar with a basic flexbox layout.

System: Firefox 78.11.0esr (64-bit) on Debian Buster

The below code or this codepen reproduces the issue (which would need the Helvetica font to be available. If not, maybe you can try some other font too.)

Relevant css properties are:

  1. html {line-height:1.15} included in normalize code.
  2. font-family: Helvetica; included in user code.

If either of the above is removed, the issue goes away.

For a future major release if any, its worth thinking about the use of html{line-height:1.15} used by normalize because:

  1. Browsers seem to set default line-height based on font-family.
  2. There are related normalize issues (612, 735, 769, 783, 788)

Code to reproduce the issue:

<!doctype html>
<html lang="en">
  <head>
    <title>Unexpected scroll bar</title>
  </head>
  <style>
    html, body {
        height: 100%;
        margin: 0px;
    }
    
    html
    {
        line-height: 1.15; /* fix: remove just this line. */
    }
    
    body {
        display: flex;
        flex-direction: column;
    }
    
    #a {
        flex: 1 0 auto; 
    }
    
    #b {
        font-family: Helvetica;  /* With Arial, no issue */
        flex: 0 1 auto; 
    }
  </style>
  <body>
    <div id="a">ABCDEFGHIJKLMNOPQRSTUVWXYZ</div>
    <div id="b">ABCDEFGHIJKLMNOPQRSTUVWXYZ</div>
  </body>
</html>

kayomarz avatar Aug 09 '21 06:08 kayomarz

In my normalize in https://github.com/garrettw/vitals I have this set to line-height: normal; instead.

garrettw avatar Feb 15 '23 18:02 garrettw