em字体大小单位是多少?多少像素? [英] What is the em font-size unit? How much is it in pixels?

查看:366
本文介绍了em字体大小单位是多少?多少像素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道什么是em单位,以及转换为像素(px)时多少个1em.我还读过一些有关IE错误的文章,以克服应将哪种主体字体大小设置为某种大小,但不能遵循太多的问题.有人可以详细解释吗?

I want to know what the em unit is, and how much 1em is when converted to pixels (px). I also read somewhere about some IE bug, to overcome which body font-size should be set to something, but couldn't follow much. Can somebody explain that in detail?

推荐答案

尽管您在其他地方可能会读到什么,但是em和px之间没有没有直接关系.

Despite what you may read elsewhere, there is no direct relationship between em and px.

作为链接状态之一:

"em"值基于 在大写字母M的宽度上

the "em" value is based on the width of the uppercase M

因此每种字体都会有所不同.窄字体可能与扩展字体具有相同的高度(以px为单位),但是em大小会有所不同.

So it's going to be different for every font. A narrow font might have the same height (in px) as an extended font, but the em size will be different.

三年后

现在有许多资料表明1em =字体大小(以px为单位).也就是说,当您编写font-size:16px时,则1em = 16px.这仍然与Adobe来源(在1c = pt中的字体大小)上不一致,但是在两种情况下都显得很奇怪.如果使用压缩字体,则em大小太大,使用扩展字体时,em大小太小.

There are now lots of sources which say that 1em = font size (in px). That is, when you write font-size:16px, then 1em = 16px. This still doesn't agree with the Adobe source (which says 1em = the font size in pt), but in either case it seems bizarre; the em size would be far too large with condensed fonts and far too small with extended fonts.

我要做一些测试页,亲自看看.

I'm going to make some test pages and see for myself.

还有:

我看到没有人(包括我)真正回答了这个问题(有点隐瞒):

I see that nobody (including me) actually answered the question (which was kind of hidden):

我还在某处读了一些bug,并克服了将字体大小设置为某种东西的问题

I also read somewhere about some ie bug and to overcome that set body font-size to something

根据此页面,您需要将此添加到CSS:html{ font-size:100%; }.该页面已有6年的历史,而且我还没有阅读(数百条)评论,所以我不知道它是否仍然有用.

According to this page, you need to add this to your css: html{ font-size:100%; }. That page is six years old, and I haven't read the (hundreds) of comments, so I don't know if it's still relevant.

这篇关于em字体大小单位是多少?多少像素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆