Media queries with rem units in Chrome?

后端 未结 3 1021
说谎
说谎 2021-01-06 07:55

Is it possible to use rem units in Chrome media queries?

rem units work flawlessly in Chrome, it just seems that they are not supported in

3条回答
  •  星月不相逢
    2021-01-06 08:35

    The spec says this about relative units such as both rem and em:

    Relative units in media queries are based on the initial value, which means that units are never based on results of declarations. For example, in HTML, the ‘em’ unit is relative to the initial value of ‘font-size’.

    (The initial value of font-size is medium, which is usually equal to the default font size setting in the browser's user preferences.)

    Since Media Queries 3 doesn't define special rules for any specific units besides the above quote on relative units, rem should act like em, working off the initial value of font-size. If it doesn't work in Chrome, it's most likely a bug.

提交回复
热议问题