IE在两个地方后删除小数点? [英] IE rips decimals after two places?
问题描述
我有一个情况,我使用动态使用
。一切都与moz和ff一起工作,因为他们以 width
到 div
jQuery 100/7 +%
作为 14.2857%
IE正在把它作为 14.28%
,这正在改变我的UI,因为14.28 * 7只有99.96。
I have a situation where i'm giving width
to a div
dynamically using jQuery
. Everything is working good with moz and ff since they are taking 100/7+"%"
as 14.2857%
where as IE is taking it as 14.28%
which is screwing up my UI as 14.28*7 is only 99.96.
有一个解决方案,使我的ie需要三个或四个小数?我尝试把我的输出四舍五入,也尝试使用 toFixed(3)
这不工作。
is there a solution to make my ie take three or four decimals?? I've tried rounding my output to three, also tried using toFixed(3)
which are not working.
提前致谢。
推荐答案
我建议你使用像素。因为你正在使用jQuery,你可以访问$(window).width()和$(screen).width()或$(parentelement).width()所以有你的100%。
I would recommend that you work in pixels instead. Since you are using jQuery anyway, you have access to $(window).width() and $(screen).width(), or $(parentelement).width() so there's your 100%. Then all pixel measurements are guaranteed to be integer by definition.
然后
$("#mydiv").width($(window).width() / 7);
也许不是你想要的解决方案,但是我们所有的开发人员都以像素为标准。我们发现在实践中效果很好。
Maybe not the solution you wanted but we have all our developers work in pixels as a standard. We find that works well in practice.
这篇关于IE在两个地方后删除小数点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!