字体大小范围 {1, 2, 3, 4, 5, 6, 7} 和 {xx-small, x-small,small,medium,large,x-large,xx-large 之间是否存在事实上的关系}?
在 HTML/CSS 中,字体大小可以通过以下方式指定(已弃用,但所有浏览器都支持):
<font size="n">text</font>
使用 n
元素 {1, 2, 3, 4, 5, 6, 7}
。
另一种可能性如下:
<span style="font-size: s;">text</span>
s
的元素为{xx-small, x-small,small,medium,large,x-large,xx-large}
。
这两个范围之间是否存在事实上的关系?我认为它们指的是相同的尺寸,因为它们都有七个元素,但事实并非如此。
In HTML/CSS font size can be specified in the following fashion (deprecated but all browsers support it):
<font size="n">text</font>
with n
an element of {1, 2, 3, 4, 5, 6, 7}
.
Another possibility is the following:
<span style="font-size: s;">text</span>
with s
an element of {xx-small, x-small, small, medium, large, x-large, xx-large}
.
Is there any de-facto relation between the two ranges? I figured they refer to the same sizes, as they have both seven elements, but that turns out not to be the case.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
请不要使用这两种方法来指定字体大小。它们被弃用是有充分理由的。使用您所描述的方法在跨平台上创建一致的外观和感觉几乎是不可能的——更不用说您完全依赖于浏览器供应商为每个平台指定的值。
相反,请使用 em 或百分比。您将获得更加一致的外观,并且可以更好地控制设计所需的字体大小。
Please don't use either of those methods for specifying font-size. They were deprecated for good reason. It is nigh-impossible to create a consistent look and feel across platforms using the methods you described -- not to mention that you become completely dependent on the browser vendors for what they specify as the values for each of these.
Instead, use ems or percentages. You will get a much more consistent appearance, as well as having much finer control over the sizes of fonts your design demands.
简短回答:不,这是特定于浏览器的。它们之间没有标准映射。
长答案:查看此文档*,因为它正在讨论同一问题的详细信息。
* 链接已失效。这是存档版本
Short answer: No, it's browser specific. There's no standard mapping between them.
Long answer: check this document* as it is discussing the same issue in details.
* link is dead. Here is an archived version
蒂姆,参考您对 Matt Howell 的回答:
如果您有 在 Firefox 中运行的 Firebug 您可以看到元素的“计算样式” - 因此,例如,当 StackOverflow css 将 h2 标签(即“您的答案”标题周围)定义为:
如果我看一下“计算样式”我可以看到这是:
这可能会帮助您完成任务。
Tim, in reference to your comment on Matt Howell's answer:
If you have Firebug running in Firefox you can see the "Computed Style" of elements - so for example while the StackOverflow css defines the h2 tag (i.e. around the "Your Answer" heading) as:
If I take a look at the "Computed Style" I can see that this is:
Which may help you in your quest.
我认为尺寸之间的(推荐)缩放系数是 1.2。 CSS 不需要缩放因子。
I think the (recommended) scaling factor between sizes is 1.2. CSS doesn't require a scaling factor.