我需要转换<font size="10">
为 px。
仅示例(不正确):<font size="10">
相当于 12px。
是否有任何公式或表格转换可以转换<font size="10">
为 px?
<font size=1>- font size 1</font><br>
<span style="font-size:0.63em">- font size: 0.63em</span><br>
<font size=2>- font size 2</font><br>
<span style="font-size: 0.82em">- font size: 0.82em</span><br>
<font size=3>- font size 3</font><br>
<span style="font-size: 1.0em">- font size: 1.0em</span><br>
<font size=4>- font size 4</font><br>
<span style="font-size: 1.13em">- font size: 1.13em</span><br>
<font size=5>- font size 5</font><br>
<span style="font-size: 1.5em">- font size: 1.5em</span><br>
<font size=6>- font size 6</font><br>
<span style="font-size: 2em">- font size: 2em</span><br>
<font size=7>- font size 7</font><br>
<span style="font-size: 3em">- font size: 3em</span><br>
使用已接受答案中的数据点,您可以使用多项式插值来获得公式。
WolframAlpha 输入:插值多项式 {{1,.63},{2,.82}, {3,1}, {4,1.13}, {5,1.5}, {6, 2}, {7,3}}
公式:0.00223611x^6 - 0.0530417x^5 + 0.496319x^4 - 2.30479x^3 + 5.51644x^2 - 6.16717x + 3.14
并在 Groovy 代码中使用:
导入 java.math.* def 转换 = {x -> (0.00223611*x**6 - 0.053042*x**5 + 0.49632*x**4 - 2.30479*x**3 + 5.5164*x**2 - 6.167*x + 3.14)。 setScale(2, RoundingMode.HALF_UP) } (1..7).each { i -> println(convert(i)) }
字体大小到 em 的映射只有在没有定义字体大小的情况下才是准确的,并且当您的容器设置为不同的大小时会发生变化。
以下对我来说效果最好,但它不考虑 size=7 并且大于 7 的任何东西都只呈现为 7。
font size=1 = font-size:x-small
font size=2 = font-size:small
font size=3 = font-size:medium
font size=4 = font-size:large
font size=5 = font-size:x-large
font size=6 = font-size:xx-large
这真的很旧,但<font size="10">
大约 <p style= "font-size:55px">
这不是那么容易回答的。这取决于使用的字体和每英寸点数 (ppi)。这应该给出问题的概述。