字体大小范围 {1, 2, 3, 4, 5, 6, 7} 和 {xx-small, x-small,small,medium,large,x-large,xx-large 之间是否存在事实上的关系}?

发布于 2024-08-04 09:27:56 字数 434 浏览 2 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

毅然前行 2024-08-11 09:27:56

请不要使用这两种方法来指定字体大小。它们被弃用是有充分理由的。使用您所描述的方法在跨平台上创建一致的外观和感觉几乎是不可能的——更不用说您完全依赖于浏览器供应商为每个平台指定的值。

相反,请使用 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.

百善笑为先 2024-08-11 09:27:56

简短回答:不,这是特定于浏览器的。它们之间没有标准映射。

长答案:查看此文档*,因为它正在讨论同一问题的详细信息。


* 链接已失效。这是存档版本

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

痴情 2024-08-11 09:27:56

蒂姆,参考您对 Matt Howell 的回答

如果您有 在 Firefox 中运行的 Firebug 您可以看到元素的“计算样式” - 因此,例如,当 StackOverflow css 将 h2 标签(即“您的答案”标题周围)定义为:

h2 {
  font-family:Trebuchet MS,Helvetica,sans-serif;
  font-size:140%;
  font-weight:bold;
  margin-bottom:7px;
}

如果我看一下“计算样式”我可以看到这是:

font-size: 17.9167px

这可能会帮助您完成任务。

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:

h2 {
  font-family:Trebuchet MS,Helvetica,sans-serif;
  font-size:140%;
  font-weight:bold;
  margin-bottom:7px;
}

If I take a look at the "Computed Style" I can see that this is:

font-size: 17.9167px

Which may help you in your quest.

秋意浓 2024-08-11 09:27:56

我认为尺寸之间的(推荐)缩放系数是 1.2。 CSS 不需要缩放因子。

I think the (recommended) scaling factor between sizes is 1.2. CSS doesn't require a scaling factor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文