Skip to content Skip to sidebar Skip to footer

Ie Rips Decimals After Two Places?

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 t

Solution 1:

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.

then

$("#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.

Post a Comment for "Ie Rips Decimals After Two Places?"