Why does “vertical-align: middle” push text below surrounding text?

≯℡__Kan透↙ 提交于 2020-02-04 00:41:13

问题


Eg.

1234<span style="vertical-align: middle">567</span>890

Will render with 567 slightly below the surrounding numbers.

http://jsfiddle.net/zBy9D/


回答1:


As mentioned by others, elements have a vertical-align of baseline by default.

In regards to why middle is lower than baseline, MDN says the following:

middle

Aligns the middle of the element with the middle of lowercase letters in the parent.

Since the height of the font text is greater than that of lowercase letters, the text becomes slightly lower.




回答2:


It's because text has, by default, vertical-align: baseline. Middle's slightly lower than baseline.



来源:https://stackoverflow.com/questions/21115195/why-does-vertical-align-middle-push-text-below-surrounding-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!