如果我使用以下CSS:
p {
font-size: 20.5px;
}
是否所有浏览器都将其绘制为20.5px,或者某些值是否为圆形?
答案 0 :(得分:4)
在所有浏览器中,小数都不会一致地舍入。我能找到的最好的帖子是:Browser Rounding
这包含一个显示以下内容的表:
Internet Explorer 7 truncate to 2 decimal places
Internet Explorer 8 truncate to 2 decimal places
Internet Explorer 9 truncate to 2 decimal places
Internet Explorer 10 truncate to 2 decimal places
Internet Explorer 11 truncate to 2 decimal places
Firefox 3.0 truncate to 3 decimal places
Firefox 3.5 truncate to 3 decimal places
Firefox 31 truncate to 3 decimal places
Chrome 20 round to 15 decimal places
Chrome 21 round to 15 decimal places
Chrome 37 round to 13 decimal places
Safari 6 (OSX Lion) round to 15 decimal places
Safari 6.1 (OSX Mountain Lion) round to 15 decimal places
Safari 7 (OSX Mavericks) round to 15 decimal places
Mobile Safari 7 (iOS7) round to 15 decimal places
Mobile Safari 8 (iOS8) round to 15 decimal places
Chrome 36 (Jelly Bean) [Nexus5] round to 15 decimal places
Chrome 30 (KitKat) [S5] round to 15 decimal places
Android Browser 4 (Jelly Bean) [Nexus7,Nexus4,S4,S3] round to 15 decimal places
Android Browser 4 (Ice Cream Sandwich) [Nexus,KindleFire2] round to 15 decimal places
Android Browser 4 (Gingerbread) [S2] truncate to 3 decimal places
Opera 12 truncate to 2 decimal places
Opera Next 24 round to 13 decimal places
答案 1 :(得分:2)
所有最新版本的浏览器允许子像素渲染* 。请参阅research和differences between browser versions的表格。
较旧的浏览器大多将像素向下舍入。最值得注意的例外是IE8和IE9,它们舍入到最接近的整数(IE7也向下舍入,IE10和向上使用子像素渲染)。
*如果您以百分比定义大小,则像素值可能会有所不同,就像您以像素直接定义它一样。