Chrome's behavior is strange when the character size of placeholder is reduced with input tag.

Asked 1 years ago, Updated 1 years ago, 423 views

inputI wanted the placeholder character size of the tag to be smaller than the normal input character size.
Therefore, we applied the following css.

input{
  max-height —40px;
  padding —8px;
  font-size: 32px;
}
input::placeholder {
  font-size: 16px;
}

When I looked at the input in this style, I found that the placeholder in Safari, Firefox was placed in the upper and lower center, but Chrome had the placeholder placed slightly below the upper and lower center.
Enter a description of the image here

  • How do I return the placeholder character position on Chrome to the top and bottom center?
    -- Safari and FireFox are also in the upper and lower center.

As a result, Chrome is up and down in the center, but this time Safari's placeholder is placed above the center.

input{
  max-height —40px;
  padding —8px;
  font-size: 32px;
}
input::placeholder {
  font-size: 16px;
}
input::- webkit-input-placeholder 
  position:relative;
  top : -4px;
}

Enter a description of the image here

css

2022-09-30 22:05

1 Answers

Google Chrome is like placing placeholders along a perimeter baseline, so it's hard to say it's funny.

vertical-align:middle doesn't seem to work either, so

  • Leave it unattended
  • Develop to apply position:relative;top:-4px only for Google Chrome

I think that would be fine.


2022-09-30 22:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.