I have a simple website with no graphics.
I am trying to implement two columns with fixed width.
The left column div#left is for navigation.
The right column div#main has all the content and is comprised of all <p>.
For some of the pages, the entire two columns is shifted slightly to the left by about 1/8".
Any idea what is causing this. I am completely stumped.
{
padding:0;
margin:0;
}
body
{
font-family:verdana, geneva, arial, sans-serif;
font-size:12px;
background:#ffffff;
color:#000000;
}
Hi, ieee488. It’s a bit hard to guess exactly what the HTML looks like and CSS without the HTML is largely meaningless. Please use the link in my signature at the bottom of this post and review our posting guidelines. It helps us give better answers.
Here’s a guess, though.
left and right padding and margins add to the width of a fixed width container, unless you use CSS3’s
{box-sizing:border-box; -moz-box-sizing:border-box;}
so the width may be expanding a little because margins, padding or borders on the outer containers (or possibly inner containers with fixed widths) have not been figured into the total width.
<p> Aliquam bibendum auctor nisi, eu blandit tellus dapibus a. Ut vulputate, velit id posuere congue, mi odio varius sem, id fermentum mi velit vitae lacus. Aliquam ut tincidunt nibh. Donec sed purus sollicitudin, molestie justo eget, pretium mi. Vivamus pellentesque nisi in purus rutrum, nec porttitor eros blandit. Proin orci dolor, blandit sit amet diam vel, mollis luctus enim. Nam blandit justo posuere lorem semper euismod. Nulla vel dui tortor.</p>
<p>Morbi ut urna ac velit pellentesque ultricies. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque nec odio non orci interdum suscipit id pretium justo. Nunc dapibus posuere erat, et imperdiet nisl volutpat et. Morbi quis vehicula justo. Nunc et porta ante. Nam dignissim leo erat, at dapibus tortor cursus a. Proin consectetur diam id mauris blandit malesuada ac nec tortor. Pellentesque egestas justo lacus, id condimentum ipsum tincidunt vitae. Vestibulum vulputate elit nisi, ac interdum quam tempor at. Nam tincidunt ac velit at aliquet. Donec id congue nulla. In luctus, mauris eget tempor sagittis, tortor metus cursus sapien, sit amet dapibus ligula lectus et leo. Maecenas ut elit sed quam viverra faucibus id vitae justo. Ut nec sem nibh.</p>
Hmmm. The code renders with a width of 1000px for me in FF on a PC. The only thing seems to be missing is a way to clear the floats. You could add {overflow:hidden} to Content, or employ a modern clearfix technique instead. I lean toward using clearfix for outermost containers, but overflow:hidden doesn’t seem be be a problem here, so it might be OK.
If you can post a link to a test site, or the actual site if it is live, I could compare pages and should be able to spot the cause.
BTW - posting code within [noparse]
[/noparse] tags preserves formatting and does not take up as much vertical space in a post.
I just had a thought… is it possible that the length of the content on some pages triggers the vertical scrollbar, thereby shifting the page to the left?