px、pt、em、ex和in等都是我们常用的长度单位,尤其在网页设计写css样式的时候需要经常用到。本文就介绍一下这些单位之间是如何换算的,同时提供一个对照表,以便在写css样式的时候做参照。
pt与px之间的换算公式
pt=px乘以3/4 或者 pt=0.75px
px与em之间的换算公式
1em=16px
px、em、pt、百分比换算表
Pixels | EMs | Percent | Points |
6px | 0.375em | 37.50% | 5pt |
7px | 0.438em | 43.80% | 5pt |
8px | 0.5em | 50% | 6pt |
9px | 0.563em | 56.30% | 7pt |
10px | 0.625em | 62.50% | 8pt |
11px | 0.688em | 68.80% | 8pt |
12px | 0.75em | 75% | 9pt |
13px | 0.813em | 81.30% | 10pt |
14px | 0.875em | 87.50% | 11pt |
15px | 0.938em | 93.80% | 11pt |
16px | 1em | 100% | 12pt |
17px | 1.063em | 106.30% | 13pt |
18px | 1.125em | 112.50% | 14pt |
19px | 1.188em | 118.80% | 14pt |
20px | 1.25em | 125% | 15pt |
21px | 1.313em | 131.30% | 16pt |
22px | 1.375em | 137.50% | 17pt |
23px | 1.438em | 143.80% | 17pt |
24px | 1.5em | 150% | 18pt |
转载请注明:知识蚂蚁 » css中常用长度单位px/em/pt/百分比转换公式与对照表