问题描述
各浏览器对于计算后宽度和高度为含有小数的长度值时,其最终值会不一致。本文地址:本帖为以上问题的讨论专区,欢迎踊跃发帖,提出您的宝贵意见和建议,谢谢!
解决方案
本帖最后由 WebAdvocate 于 2010-09-01 17:48:36 编辑
解决方案二:
你好,我在w3help上拜读了你的文章,但是有一个地方,我觉得有点疑惑就是根据w3c的文档:6.1.3UsedvaluesComputedvaluesareprocessedasfaraspossiblewithoutformattingthedocument.Somevalues,however,canonlybedeterminedwhenthedocumentisbeinglaidout.Forexample,ifthewidthofanelementissettobeacertainpercentageofitscontainingblock,thewidthcannotbedetermineduntilthewidthofthecontainingblockhasbeendetermined.Theusedvalueistheresultoftakingthecomputedvalueandresolvinganyremainingdependenciesintoanabsolutevalue.6.1.4ActualvaluesAusedvalueisinprinciplethevalueusedforrendering,butauseragentmaynotbeabletomakeuseofthevalueinagivenenvironment.Forexample,auseragentmayonlybeabletorenderborderswithintegerpixelwidthsandmaythereforehavetoapproximatethecomputedwidth,ortheuseragentmaybeforcedtouseonlyblackandwhiteshadesinsteadoffullcolor.Theactualvalueistheusedvalueafteranyapproximationshavebeenapplied.根据这两句话不知可否理解为,当浏览器在对页面进行布局时就讲百分比进行了转换,就是说布局后页面将所有的值已转换为绝对的值,最后在页面渲染时,在讲小数值进行近似计算。对于小数的处理,我觉得可以参考这个页面写的:http://ejohn.org/blog/sub-pixel-problems-in-css/