body { font-size: 100.01%; } vs body { font-size: 100%; }?

后端 未结 3 1071
遇见更好的自我
遇见更好的自我 2021-02-02 15:18

What should i keep for body, {font-size: 100.01%; } or { font-size: 100%; }?

what is {font-size: 100.01%; }? and is i

相关标签:
3条回答
  • 2021-02-02 15:52

    The declaration body (or html) { font-size: 100.01% } compensates rounding errors, in particular in older versions of Opera and Safari. Both would otherwise display fonts that are too small.

    A relative font-size (%, em) is always interpreted relative to the font size of the parent element. So it's not a bad idea to implement kind of a initial reset in the top element, which you can achieve with body {font-size: 100%}.

    0 讨论(0)
  • 2021-02-02 15:56

    Never seen 100.01% before, but it seems like some sort of browser hack that will force some browsers to ignore or calculate size correct if you use this "fix".

    I wouldn't use it myself though, as errors tends to be fixed and there are often more nice ways of dealing with the same option.

    0 讨论(0)
  • 2021-02-02 15:57

    html { font-size: 100.01%; }

    100.01%, not a hack or a kludge, has been around for many years. Google "100.01%" and read up. It is as valid as 100% and does cover some territory 100% doesn't.

    An initial font-size should always be declared. Set a base font-size on an outer container -- either <html> or <body> -- for it is from that container which all relative and inherited font-size values will derive. Using 100% or 100.01% makes the starting font-size equal to the user's browser preference.

    Setting that base font-size to the user's browser preference gives your visitors maximum readability. Read that again, please, about the USER's preference. Your visitor will have set their browser font-size for their own best legibility and reading comfort. Your design, magnificent and fragile though it may be, is only a second-string player. Content is king, assuming you have some. But if that content is un-readably tiny, you lose. The visitor surfs on. Your design, then, has failed your needs and your expectations. Therefore, the design really wasn't all that great, was it?

    0 讨论(0)
提交回复
热议问题