Solved

Background not centered correctly with website

Posted on 2006-10-25
2
216 Views
Last Modified: 2011-10-03
I have a 770px x 1px white image that lays right in the middle at the top of a page and continues repeating vertically, so it looks like a white column. Well, after putting a footer on the page, it looks like it's off-center. My table is set to 770px wide (same width as the background) and set to center of the page. Can anyone help me?

Here's a pic of what I'm talking about:  http://img110.imageshack.us/my.php?image=cssproblemul8.jpg


And here's what my CSS looks like:

body {
      font-family: Tahoma, Arial, sans-serif;
      font-size: 11px;
      font-weight: normal;
      color: #000000;
      background: url(../../images/backgnd.gif) repeat-y top center #000000;
      margin-top: 0px;
      margin-left: 0px;
}
0
Comment
Question by:ecosvaldo
2 Comments
 
LVL 16

Accepted Solution

by:
HackneyCab earned 50 total points
ID: 17805207
You're using a table for layout? That's not a great idea.

To centre the body element, use this:

margin-left: auto;
margin-right: auto;

or use this for a shortcut:

margin: 0px auto;

which sets the top and bottom margins to zero, and the left and right to auto. Which should centre the body element within the html element.

Use the same setting to centre other elements within the body element.

Using tables for layout is generally frowned upon these days, for several reasons.
0
 

Author Comment

by:ecosvaldo
ID: 17805415
Thanks HackneyCab! You helped me out.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question