pt——绝对长度;px——相对长度
CSS相对长度单位 | 说明 |
em | 元素的字体高度The height of the element's font |
ex | 字母x的高度The height of the letter "x" |
px | 像素Pixels |
% | 百分比Percentage |
CSS绝对长度单位 | 说明 |
in | 英寸Inches (1 英寸 = 2.54 厘米) |
cm | 厘米Centimeters |
mm | 毫米Millimeters |
pt | 点Points (1点 = 1/72英寸) |
pc | 皮卡Picas (1 皮卡 = 12 点) |
在所有浏览器中,为显示相同的文本大小,并允许所有浏览器缩放文本的大小,可参考以下代码:
<style>
body {font-size:100%;}
h1 {font-size:2.5em;}
h2 {font-size:1.875em;}
p {font-size:0.875em;}
</style>