Normalize.css: iOS placeholder line-height with some fonts

Created on 28 Mar 2018  路  4Comments  路  Source: necolas/normalize.css

On iOS 10, with certain fonts, the vertical alignment of input placeholders is broken because of a strict line-height defined in normalize.css.
https://github.com/necolas/normalize.css/blob/7369f566898b8cefc2649b6a66e112857de4c46f/normalize.css#L159

In my particular case I have a font Galano Grotesque Alt, and here is how my input looks on iOS:
image

If I change the line-height to normal, iOS fixes the layout:
image

I can鈥檛 make an interactive example because the font is not freely available.

This only happens with the placeholder, only on iOS, only with this font in my case. If I start typing in, it aligns correctly:
image

A general problem with vertical alignment of the placeholder in iOS seems to be prevalent. A web search finds numerous relevant questions on Stack Overflow.

The line-height change was introduced in #607 and is nicely explained in a comment on #591.

I don鈥檛 suggest to change that line-height right now. The interaction is obscure, and there seems to be value in the value of line-height as is. I want to preserve this research in case anyone else stumbles in a similar scenario and searches the issue tracker for the issue. So feel free to close this immediately as inactionable, or keep open if you want to ponder more about it.

Most helpful comment

For whatever reason, I needed:

::placeholder {
  line-height: normal !important;
  vertical-align: middle;
}

All 4 comments

@denis-sokolov The following could fix your problem 馃憤

::placeholder {
    line-height: normal;
}
input::placeholder,
input::-webkit-input-placeholder,
input::-moz-placeholder {
  line-height: normal !important;
}

For whatever reason, I needed:

::placeholder {
  line-height: normal !important;
  vertical-align: middle;
}

I had the same problem and I fixed with

input {
  -webkit-appearance: none;
  border-radius: 0;
 :focus {
    outline: none;
    border-radius: 0;
  }
  :active {
    border-radius: 0;
  }
}

Note1: I probably don't need active and focus but I add just in case.

Note2: If the font size is smaller than 16px you might have some zoom issues.
Check out this article for more info: https://thingsthemselves.com/no-input-zoom-in-safari-on-iphone-the-pixel-perfect-way/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gitowiec picture gitowiec  路  6Comments

josephfusco picture josephfusco  路  6Comments

ibrahemMR picture ibrahemMR  路  3Comments

visicode picture visicode  路  6Comments

FDiskas picture FDiskas  路  3Comments