Skip to content

android浏览器下line-height垂直居中为什么会偏离? #11

Description

@HuarenYu

知乎相关讨论

原因:

移动端web字体小于12px;

可能是字体的原因。

解决方案:

针对移动端字体小于12px文字不垂直居中的解决方法:

方法1:把小于12px的字体改为12px。(有小偏差)

方法2:把字体扩大一倍,然后使用transform:scale(0.5)缩小一半,代码如下:(有小偏差)

方法3:给元素外层再包一层父元素,用display:table来实现。(效果比较好)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions