Solved

Background not centered correctly with website

Posted on 2006-10-25
2
209 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jquery, html5 UI 1 62
How can I make a css class read only with jquery? 2 37
Gradient CSS 4 30
Centering Vertically 3 28
When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

863 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now