什么是em font-size?它是多少像素? [英] What is em font-size? How much is it in pixels?

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

问题描述

我想知道什么是em和它是多少像素。我也读了一些关于一些ie的bug,并克服那个设置体字体大小的东西,但couldnt跟随很多可以有人详细解释。

解决方案

尽管您可能在其他地方阅读过,但em和px之间仍存在没有的直接关系。




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


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



编辑三年后: strong>



现在有很多来源说1em =字体大小(以px为单位)。也就是说,当你写 font-size:16px ,然后1em = 16px。这仍然不同意Adobe的来源(这说明1em = pt 中的字体大小),但在任何一种情况下,它似乎很奇怪; em大小会因为缩小的字体太大,而且扩展字体太大了。



我要做一些测试页面,看看自己。 p>

还有:



我看到没有人(包括我) (这是一种隐藏):


我也读了一些关于一些ie的bug,并克服了set body font-size to something


根据这个页面,你需要添加到你的css: html {font-size:100%; } 。那个页面是6岁,我没有阅读(数百)的评论,所以我不知道它是否仍然相关。


I want to know what is em and how much is it to pixels. I also read somewhere about some ie bug and to overcome that set body font-size to something but couldnt follow much can somebody explain that in detail.

解决方案

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

As one of the links states:

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

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.

EDIT three years later:

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.

And also:

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

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

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 font-size?它是多少像素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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