开发者

What does a CSS `font-size` property defined as a percentage mean?

Us开发者_C百科ing the CSS font-size property, one can specify the size as a percentage. What does this percentage refer to?


The percentage refers to the size percentage of the elements parent. I think the default browser font size is 14px, so:


  p{ font-size: 100%; } /* 14px */
  p{ font-size: 85%; } /* 12px */

It starts to get a little more complicated if you have this:


   <style type="text/css">
        div{ font-size: 20px; }
        p{ font-size: 80%; } /* 16px */
   </style>

   <div>
       <p>Some Test</p>
   </div>

Since I set a pixel size for the parent div, and a percentage size for the child paragraph, the child paragraph uses the parent pixel size as the base measurement.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜