css中调整字体大小的最终方法

发布于 2024-09-03 06:46:14 字数 625 浏览 2 评论 0原文

我想了解经验丰富的开发人员的一些意见,了解他们认为确定字体大小的最终方法(基本意义上)。我知道使用 ems 被认为是最好的,但我指的是设置基本字体大小的最佳方法。

有一种使用 62.5 方法将字体设置为 10px 的技术,但我认为 ie 有一个舍入问题,这会稍微抛出这个问题(也许不是)

YUI 框架使用

body {
font:13px/1.231 arial,helvetica,clean,sans-serif;
/* for IE6/7 */ 
*font-size:small; 
/* for IE Quirks Mode */
*font:x-small; 

}

这真的让我很困惑!

的黎波里使用

html
{
   font-size:125%;
}

body
{
    font-size:50%;
}

一个列表来建议一些类似于以下内容的内容:

body {

font-size: 16px;
*font-size: 100%;

}

那么,在这些方法或任何替代方法中,哪种方法是最好的。最好的是最容易使用和最可靠的跨浏览器。

I would like to know some opinions from experienced developers on what they think the definitive way to size fonts (in a base sense). I know that working with ems is considered best but im referring to the best way to set the base font size.

There is the technique of setting font to 10px using 62.5 method but i think ie has an issue with rounding which throws this out slightly (perhaps not)

YUI framework uses

body {
font:13px/1.231 arial,helvetica,clean,sans-serif;
/* for IE6/7 */ 
*font-size:small; 
/* for IE Quirks Mode */
*font:x-small; 

}

which really confuses me!

Tripoli uses

html
{
   font-size:125%;
}

body
{
    font-size:50%;
}

a list apart suggest something along the lines of :

body {

font-size: 16px;
*font-size: 100%;

}

So which is the best either out of these methods or any alternatives. The best being the easiest to work with and the most reliable cross browser.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

我不咬妳我踢妳 2024-09-10 06:46:14

最近,人们又回到了直接像素大小调整,因为所有现代浏览器的缩放功能现在都按比例增加所有内容,而不是像以前的版本那样仅仅增加字体大小。 12px 是我见过的标准文本的标准基本尺寸。

Well lately people have been going back to straight pixel sizing because all the modern browsers Zoom functionality increases everything proportionally now, rather than just increasing the font size as in previous versions. 12px is the standard base size for standard text that I've seen.

漆黑的白昼 2024-09-10 06:46:14

有设置字体的技巧
使用 62.5 方法到 10px 但我认为
即有一个舍入问题
稍微抛出这个(也许不是)

这是我每天使用的技术,如果存在这样的错误,我没有因此遇到任何 IE 错误。使用 em 真的很容易,只要你能在不使用计算器的情况下除以十!您只需对 hN、li、p 等元素使用 font-size 属性,但不要尝试同时调整父 div 或块引用以及子段落和标题的大小,否则子元素没有 10px<-> ;1em 不再等价。

如果您使用 CSS 框架,请遵循它使用的方法。

题外话,我使用条件注释,没有明星黑客。曾经。

也就是说,你的问题没有明确的答案(某人在最近的一个话题上写了“em vs px 是一场圣战”,恕我直言,他是完全正确的)。

从可访问性的角度来看,这里有一个相应的充分技术: C14:使用 em字体大小的单位 - WCAG 2.0 这不是实现成功标准 1.4.4 调整文本大小

Except for captions and images of text, text can be resized without assistive technology up to 200 percent without loss of content or functionality. (Level AA) 

C12 是相同的,只有百分比,据我所知,其他不是跨浏览器兼容。

There is the technique of setting font
to 10px using 62.5 method but i think
ie has an issue with rounding which
throws this out slightly (perhaps not)

That's the technique I use daily and I didn't encounter any IE bug due to this, if such a bug exists. Working with em is then really easy, as long as you can divide by ten without using a calc! You just have to use font-size property with elements like hN, li, p and so on but don't try to size both a parent div or blockquote and child paragraphs and headings otherwise children elements don't have the 10px<->1em equivalence anymore.

If you use a CSS framework, stick to the method it uses.

Off topic, I use conditional comments and no star hacks. Ever.

That said, there's no definitive answer to your question (sb wrote 'em vs px is an holy war' on a recent topic and (s)he is quite right IMHO).

From an accessibility point of view, here is a corresponding sufficient technique : C14: Using em units for font sizes - WCAG 2.0 It's not the only way to achieve Success Criteria 1.4.4 Resize text:

Except for captions and images of text, text can be resized without assistive technology up to 200 percent without loss of content or functionality. (Level AA) 

C12 is the same, only with percentages, others aren't, as far as i remember, as cross-browser compatible.

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