Font sizes in UIWebView does NOT match iOS font size

前端 未结 3 524
北恋
北恋 2021-01-11 12:26

Here\'s a UILabel which says \"About\". Set at exactly 17.7 in iOS.

Below it a UIWebView which also says \"About\". Also set at exactly 17.7 using css.

3条回答
  •  时光说笑
    2021-01-11 13:02

    Yep, its a parent font-size issue:

    You should always set the font-size for body to 16px (one can set it higher if a larger base font is required, the standard is 16px).

    Then, set font sizes using 16px as the base.

    body {
        font-size: 16px;
    }
    
    h1 {
        font-size: 24px;
    }
    

    If you want both the body and the h1 font-sizes to be the same then simply set the body font-size and don't set the font-size of the h1 (it will inherit the body font-size all on its own... aka... cascading).

    body {
        font-size: 16px;
    }
    
    h1 {
    
    }
    

    What you have done is set the body font-size to a value... then set the h1 font-size to that same value, the problem is that h1 inherits the font-size from body and then goes even bigger when you assign a font-size to h1.

    Hope this makes sense and helps.

提交回复
热议问题