AutoCAD 3DMAX C语言 Pro/E UG JAVA编程 PHP编程 Maya动画 Matlab应用 Android
Photoshop Word Excel flash VB编程 VC编程 Coreldraw SolidWorks A Designer Unity3D
 首页 > css教程

知识普及之CSS: body{font-size: 62.5%;}这种写法的原因

51自学网 http://www.wanshiok.com
css,62.5,font-size,,62.5%

在网页设计中我们经常看见body{font-size: 62.5%;}这样的设置,为什么偏偏是62.5%呢?这主要是为了方便em与px相互转换,em的初始值为1em=16px,显然这样的话,如1.2em则=19.2px,可是我们在设置的时候很少看见19.2px这样表示的大小,也就是在用px表示大小时数值是不带小数位的。当设置了body{font-size: 62.5%;}时,1em则=16px*62.5%=10px,1.2em则=12px,这是不是就简单多了,准确多了呢~~

CSS Code复制内容到剪贴板
  1. Set body font-size to 62.5% for Easier em Conversion   
  2. If you would like to use relative units (em) for your font sizes, declaring 62.5% for the font-size property of the body will make it easier to convert px to em. By doing it this way, converting to em is a matter of dividing the px value by 10 (e.g. 24px = 2.4em).   
  3. code:   
  4. body {   
  5.   font-size: 62.5%;   
  6. }   
  7. p {   
  8.   font-size: 1.2em;   
  9. }  

以上所述是小编给大家介绍的CSS: body{font-size: 62.5%;}这种写法的原因分析,希望对大家有所帮助!


css,62.5,font-size,,62.5%  
上一篇:CSS中灵活使用:before和:after  下一篇:详解CSS的border边框属性及其在CSS3中的新特性