that happens because your footer is over 100% width as you have a 1px border around the footer.
The width thus computes to 100% width + 1px (border left) + 1px (border right) = total width exceeds the width of the viewport.
You could set your #footer width to 99% (as an example) or leave it at 100% and remove the left and right border values.
border-top:1px solid red;
border-bottom:1px solid red;