Chrome will increase the font size when zooming out

后端 未结 2 1334
[愿得一人]
[愿得一人] 2021-01-15 00:53

I have the following code :

CSS

#container{
    font-size: 0.625em;
}

#div1 {
    width: 200px;
    height: 200px;
    background-color: green;
}
         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-15 01:09

    See, you used px for the first div and em for the second.

    Chrome has a minimum font size and fonts smaller than it will be displayed as that font size only. (see your Chrome Settings)

    Now, using div with px, the box goes on and becomes even smaller on zooming at 33% (or 25% or 50%) but using em, the box remains the same size when the minimum font-size has been reached. see

    enter image description here

    em is useful on browsers which implement zooming by scaling the font size like Chrome. So if you size all your elements using em they scale accordingly. em makes sure that the whole content is displayed as it is even if the size of div changes (on zooming). Hope you got your answer :)

    EDIT

    In IE10, there's no minimum font size in settings as in GC35. So the em px render like each other.

提交回复
热议问题