Decimal places in width using pixels
The other day I was designing a nice little tool which will drag and drop divs using the JQuery UI framework, the issue I was having was the difference in browsers on certain measurements. As it was drag and drop it was possible for the user to drag the div to a left position of 100.2px or 150.8px. But obviously you can't exactly position the div to 0.2 of a pixel because that's impossible.
So I asked the question which way does the browser round this measurement, does it round 125.8px to 125px or to 126px. I know this doesn't sound like much of difference in the display but when I am saving these values in the database to be displayed later I want the div to appear exactly where the user placed in, exact position positioning can be important for application such as wireframe programs.
I did some research into this question and discovered the answer and of course the answer is different browsers will handle it differently. Here are the results of from main browsers
As you can see for these results FireFox and IE will always round to the nearest and the other browsers will always round down.
Fastest WordPress Hosting With WPEngine
Stunning speed, powerful security, and best-in-class customer service. At WP Engine.
- Access 100s of premium tutorials and downloadable content
- Members content consists of premium WordPress plugins
- CSS packages, jQuery packages, tutorial demo files and templates for 100s of web development tutorials
- In-depth development tutorials
- Priority tutorial requests
- No ads
- First month free!