简体   繁体   English

网站CSS和字体大小 - 最佳实践

[英]Website CSS and Font Sizes - Best Practices

In my website CSS, I'm using EM, PX, PT and Percentages to set the font sizes. 在我的网站CSS中,我使用EM,PX,PT和Percentages来设置字体大小。

I am also using JQuery UI which uses EM. 我也在使用使用EM的JQuery UI。

I have now come to the point where I need to resize all the font sizes to slightly smaller. 我现在已经到了需要将所有字体大小调整为略小的地步。

All in all, what's the best what of bringing all the font sizes down a bit and should I be changing how I'm doing font sizes to whichever way? 总而言之,将所有字体大小降低一点的最佳方法是什么?我应该改变我的字体大小,无论哪种方式?

Everyone seems to have a different opinion on this topic. 每个人似乎对这个话题都有不同的看法。

As per my understanding. 据我所知。 What you must do is something like that: 你必须做的是这样的事情:

body{font-size:11px;} This will make 1em = 11px body{font-size:11px;}这将使1em = 11px

Now everywhere you'll set the font-size in em like: 现在,无论你在em设置字体大小如下:

a{font-size:1em;} and follow the same way to all the elements like h1{font-size:2em;} a{font-size:1em;}并按照相同的方式对所有元素如h1{font-size:2em;}

Now if you need to increase decrease font size just set the font size in body like: 现在,如果您需要增加减小字体大小,只需在体内设置字体大小,如:

body{font-size:13px;} etc. body{font-size:13px;}

Hope that helps 希望有所帮助

In the olden days people recommended using em for fonts, because older versions of IE didn't resize the text on zoom other wise. 在过去,人们建议使用em作为字体,因为旧的IE版本没有在缩放上调整文本的大小。

Nowadays all browsers do full page zoom instead of just text, so that's an irrelevant concern. 现在所有浏览器都进行全页缩放而不仅仅是文本,因此这是一个无关紧要的问题。 I'd recommend using px as it gives you good control. 我建议使用px,因为它可以让你很好地控制。

the best practice for sizing fonts is em. 调整字体大小的最佳做法是em。 because it is not related to users client resolution. 因为它与用户客户端解析无关。 but I use pixels in my own applications. 但我在自己的应用程序中使用像素。 because I want to render smaller fonts in higher resolutions. 因为我想以更高的分辨率渲染较小的字体。 but percent is not recommended for font size at all. 但根本不建议使用百分比字体大小。

also you can see this thread for comparison 你也可以看到这个线程进行比较

also this would help : http://kb.mozillazine.org/Em_vs._ex 这也有帮助: http//kb.mozillazine.org/Em_vs._ex

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM