font-size:62.5%vs. font-size:10px [英] font-size:62.5% vs. font-size:10px

查看:237
本文介绍了font-size:62.5%vs. font-size:10px的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很长一段时间以来,我一直在CSS文档中使用 body {font-size:62.5%;} ,因为它应该使1em等于10px。但是,我最近注意到,这不是我的情况在Internet Explorer。所以我尝试了代码 html {font-size:100%} body {font-size:10px}

For a long time I've been using body {font-size:62.5%;} in CSS documents to since it's supposed to make 1em equal 10px. However, I recently noticed that this isn't the case for me in Internet Explorer. So Instead I tried the code html {font-size:100%} body {font-size:10px}.

为我的魅力。我的问题是:

Now this works as a charm for me. My question is:

这个解决方案有什么缺点,因为我找不到任何人使用它。

What's the drawback of this solution since I can't find anyone else using it.

澄清。我后来指定所有我的字体大小,宽度,高度等等在em。它只是在身体我使用10px而不是62.5%。

to clarify. I later specify all my font-sizes, widths, heights and so forth in em. It's just in the body I use 10px instead of 62.5%.

推荐答案

问题。我猜想大多数人会争论%。

You're going to get arguments for both sides of this issue. I'm guessing a majority are going to argue for %. But you asked for drawbacks or pitfalls

你会遇到的主要缺点是,如果你运行的浏览器或设备,尊重你的像素设置,而不是它的任何百分比默认是,并且该像素设置偶尔有问题或太小,无法读取。如果该浏览器没有为用户提供缩放字体或放大页面的机会,那么您可能有潜在的问题。

The main drawback you would encounter would be if you ran across a browser or device that honored your pixel setting instead of a percentage of whatever it's default is, and that pixel setting happened to be problematic or too small to read. If that browser didn't offer the user an opportunity to either scale the font or zoom in on the page, then you could have a potential problem.

总之,几乎每个浏览器都有默认设置为16px。我不能说为什么IE在你的情况下,它的尺寸不同。如果你要去一个像素完美的大小的设计,然后使用px,否则我建议留在%。

All that said, almost every browser these days has that default set at 16px. I can't speak to why IE in your case is sizing it differently. If you are going for a pixel perfectly sized design, then use px, otherwise I'd suggest staying with the %.

这篇关于font-size:62.5%vs. font-size:10px的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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