Auto margin shifts my page content to the left

I found myself wasting about 2 hours of my time trying to understand why only one of my pages moved about 16px to the left when switching back and forth between the different page. My problem is that I was using a template and that everything on the two pages were exactly the same. Here is an example of what I mean.

Using the famous divide-and-conquer problem solving method (ha ha!), I started to remove some text to find out the culprit paragraph, and realized that the problem was only present when I had a lot of content on the page. After a few google searches, I found a thread on sitepoint’s site that explains exactly my problem (titled: Web Page Wiggle Issue and Margin Auto Wiggles & The Vertical Scrollbar). The problem lies in the use of “auto” for centering pages, much like in the very popular “body {margin: 0 auto; width: 960px;}”. This causes the page to wiggle (move to the left) between pages where the vertical scrollbar is needed (longer content) and where it doesn’t appear (firefox adds the scrollbar as needed, whereas IE always keeps it!). From the website, I found two fixes for the problem:

You can easily fix this, using CSS, by adding this one line in your stylesheet:

html {overflow-y: scroll;}

Another fix, if you are using JQuery, is the following:

$(function(){
    $('<div/>').css({
        position: 'absolute',
        top: 0,
        width: '1px',
        height: ($(window).height() + 1).toString() + 'px'
    }).appendTo('body');
});

Web Developer Extension for Mozilla-based Browsers

In the works since June 3rd 2003, the Web Developer Extension for Firefox (Any Mozilla-based browser really, including Flock!) is simply amazing. The first version, Version 0.1, had a couple of features like resizing your screen and validating the css, etc. Now, the brand new version, Version 1.0.2, came out on January 31st 2006 and is simply stunning. It allows you to do many many things, from validation of HTML, CSS, Feed, Links, etc, to editing HTML and CSS on the fly. All of this is done by adding a toolbar in your browser.

By now, you are wondering why I am that excited about the plugin ? Right. My exact reaction when I found it (My friend Clint did actually, from www.leavingbehind.com). Well, for one thing, the tool bar enables you to change code for ANY page on the web. You wonder what www.alistapart.com would look like with red text instead of grey/black text ? No worries, simply click ‘Edit CSS’ and change ‘color: #333;‘ to ‘color:#FF0000‘ in the base.css file. It’s that simple. Now, of course, this will not change the look of the page for every user on the internet, only for you, but think about the time saved by developers all over … We can finally look at the result of changing a simple little css command live in the browser. It is an amazing tool to learn XHTML and CSS as well, since you can see what a XHTML command does by changing the values and seeing the result right away.

Enough praising. Where can you find a little jewel like this ? Find it at Chris Pederick’s page. Let me know what you think. I think it’s a stunning like plugin that, so far, works perfectly fine without any bugs. Great, great piece of software!

© Copyright Bonuel Photography - Theme by Pexeto