简体   繁体   English

给定设计(1920px x 1080px)的 html 字体大小基础是多少?

[英]What is the html font-size base for a design given (1920px x 1080px)?

I'm a little confused.我有点困惑。 If I have a mockup design given (1920x1080px) and for example the paragraph has a font-size of 22px and h1 has a value of 60px, what should be the base of font-size to convert to rem?如果我有一个给定的模型设计(1920x1080px),例如该段落的字体大小为 22px,h1 的值为 60px,那么要转换为 rem 的字体大小的基础应该是什么?

html {
   font-size: 18px;
}

html {
       font-size: 100%;
    }

or should I take或者我应该采取

   html {
     font-size: 62.5%
   }

If, as @HaoWu suggests, you set如果像@HaoWu 建议的那样,您设置

html { font-size: 62.5%; }

then you are basically setting rem as 10px in most cases because most browsers will default to 16px as the base font size.那么在大多数情况下,您基本上将 rem 设置为 10px,因为大多数浏览器默认将 16px 作为基本字体大小。 It's then an easy calculation to set h1 to 60px as it's just 6rem.然后将 h1 设置为 60px 是一个简单的计算,因为它只有 6rem。

There will be occasional exceptions if the user has set the browser base size to something else.如果用户将浏览器基本大小设置为其他值,则偶尔会有例外情况。 That is their choice, perhaps because they hope for websites to automatically show bigger text.这是他们的选择,也许是因为他们希望网站自动显示更大的文本。 This means you cannot absolutely depend on 1rem being 10px.这意味着您不能绝对依赖 1rem 为 10px。 In most cases this should be fine as everything will be correctly proportional.在大多数情况下,这应该没问题,因为一切都会正确成比例。

If it is vital to your layout, and usually in a properly responsive design it won't be, that the rem has a definite px value then you need to define html font-size in px, but best not if you can avoid it.如果它对您的布局至关重要,并且通常在适当的响应式设计中它不会是,rem 具有确定的 px 值,那么您需要以 px 定义 html 字体大小,但最好不要,如果您可以避免它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM