necolas / normalize.css

A modern alternative to CSS resets
http://necolas.github.io/normalize.css/
MIT License
52.28k stars 10.67k forks source link

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

Open kayomarz opened 3 years ago

kayomarz commented 3 years ago

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>
garrettw commented 1 year ago

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