Solved

Center Web Page Not Working

Posted on 2011-02-12
5
410 Views
Last Modified: 2012-05-11
An update page I am working on  is at http://www.dciscancer.com/index2011.php

In Code View you can see:
<div id="Centered">
at the top of the body.
I close it just above  </body>

The tag is in the linked .css file a reads as follows:
Centered {
      position: relative;
      margin-left: 100px;
      margin-right: auto;
      margin-top: 0;
      margin-bottom: 0;
      width: 1024 px;
}

I use this many other websites to center the page on the browser screen.
It works at http://www.thebicyclesite.com and http://www.liccsc.org, for example.
Here it is not doing anything and I cannot figure out why.
0
Comment
Question by:glenn_1984
  • 2
  • 2
5 Comments
 
LVL 16

Assisted Solution

by:SSupreme
SSupreme earned 200 total points
ID: 34879494
Add to your css this code instead Centered:
#Centered {
    margin: 0 auto;
    position: relative;
    width: 900px;
}

Open in new window

0
 
LVL 20

Accepted Solution

by:
thehagman earned 300 total points
ID: 34879676
So before you merely edit the margin property, take a close look at SSupreme's complete CSS code: You used "Centered" instead of "#Centered", which would apply to a (ficticious) tag <Centered>...</Centered>
0
 
LVL 16

Author Comment

by:glenn_1984
ID: 34879896
I figured it was a stupid error.

I added the # to Centered...no idea why, in a long .css file I did not notice that :)

The margin: 0 auto;  has no effect.  I tested with and without.

Thanks.
0
 
LVL 16

Expert Comment

by:SSupreme
ID: 34880365
If you tested it without the width, then there is no place for margins to exist, except 0 margins. Please follow the instruction next time.
0
 
LVL 16

Author Comment

by:glenn_1984
ID: 34880527
I DID  use the width. What I did not use was  margin: 0 auto;

It is now running live at http://www.dciscancer.com.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Wordpress "chart" plugin recommendation 7 60
Width of Page is Affecting Side Menu 6 32
How to combine and minify CSS and JS files 5 19
Change box shadow 1 29
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... …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
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 …

821 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