A single line of text is centered vertically you may blurt out that the height and line-height are set to the same line, or set the same padding-top and Padding-bottom values.
It's the effect of chrome, and it's nothing to be surprised about, exactly what we expected.
Then we go to the mobile side, set the equal height and line-height, the situation becomes very strange, first (from the WebView):
This is from my charm blue, from the test there borrowed a few Android phones, basically this is shown, the text is obviously biased, and the smaller the height of the more obvious:
Put the border on ....
Because 1px border is done in the way of transform scale, suspicion is the reason for transform. First put this piece of CSS removed, the effect is very obvious, my charm blue and the Apple phone is the center, but still have a lot of Android machine still can not center, on the lower side of the have.
Also suspected that the code is not mutual influence, wrote a demo, is the above, exclude.
A pass Google, also no disorderly use, see have the answer said Line-height in mobile side performance abnormal, then I change to padding way, still no disorderly use, and iOS at this time also began biased:
and Line-height surprisingly consistent.
At that time of my heart is collapsed, how simple center incredibly so many moths, at that time in the thinking that this must be a browser rendering bug ...
After a long left to change the right. Later found that no matter how the phone on the lower side, but the PC (Chrome developer Tools mobile phone) has been stable center, I looked back to the next of my own CSS:
/* Key Code */ { height: 20px; line-height: 20px; font-size: 10px;}
Nothing unusual, but chrome for the Chinese is not support 12px below, less than 12px will be unified display 12px, a flash, is not this reason, holding the attitude to try to set the Font-size to 12px.
Even center!!!! Line-height and padding of the way are centered!!!
Locked up the problem to solve, some people say with -webkit-text-size-adjust:none , but useless, finally thought of an ultimate method:
and design wet communication ....
Finally unified changed to 12px, each cell phone finally center, but there is a cell phone is not centered, beautiful map phone!!!! Regardless of him. By the way, the phone is ugly. Icon Big ugly ... No one hit me ... A piece of ...
Looking at some of the information, Chrome just set the Chinese setting to a minimum of 12px, English is supported under 10px, and the mobile is actually support 12px of the following fonts, but it is unclear why the center exception.
So the center of the mobile 10px is normal, especially the lowercase letters.
The problem of vertical centering of mobile Web single-line text