Blog Post RSS ?

Blogs » JavaScript & CSS » Browsers, Pixels and Rounding Errors
 

Browsers, Pixels and Rounding Errors

by Alex Walker

I guess most of us have understood for a long time that browsers rarely see eye to eye when it comes to calculating percentages, whether that be in element widths, element positioning or background placements. In fact, the background percentages post I did last year demonstrated it pretty clearly.

Thanks to JQuery guru John Resig, we now have a clinical breakdown of exactly how much differently the browsers view this issue.

Read the full article for the detail, but the short version goes something like this..

If presented with a sub-pixel percentage:

  • IE6 and IE7 round the number up
  • Opera and Safari round the number down
  • Firefox employs a sort of clever but slightly weird methodology that rounds some percentages up and others down.

Is it any wonder it’s such a trial trying to get liquid columns borders to align properly? I’m not sure if knowing exactly why things are difficult makes it easier to take or harder.

This post has one response so far

  1. Always leave at least 1% of width free to be conquered by rounding and calculations… I think that’s very old tip that’s still valid nowadays.

     

Sponsored Links

Leave a response

You are not logged in, log in with your SitePoint Forum username and password.

-OR- Post Anonymously

* Make sure any code samples are escaped (i.e. ‘<b>’ becomes ‘&lt;b&gt;’).

If not logged in, your comments will be placed in a moderation queue. This means your comment may not appear until one of our moderators approves it.

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.

New Release!

The Principles Of Successful Freelancing

Book Cover: The Principles of Successful Freelancing

Become a successful freelancer TODAY!

Find out how!