It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming CSS Forum

What Code Is Required

What Code Is Required

Postby cuban on Mon Feb 05, 2007 1:57 am

First post, so please go easy on my basic knowledge. :oops:

I need to center the content of a design that is currently left-justified.
Is this done via a code in the style.ccs?

I've put the template shell up so you can see what I mean.
http://www.actworld.co.uk/index-2b.html

I'd really appreciate an answer to what is, I assume, a simple and basic question.

Thank you.
cuban
 
Posts: 3
Joined: Mon Feb 05, 2007 1:49 am

Postby jberry on Mon Mar 19, 2007 5:28 pm

it is actually pretty easy what you are asking to do. The easiest way to do it for what you have would be to add in your style sheet a div tag like this : #center {
position:absolute;
left: 175px;
}
The left will tell it how far in to indent the table so you can change that if you want to move it around.

Then in your code before <body> you would put this <div id "center">
and after table and before body at the end of the code you would put the close tag </div>

This should do just what you are looking for.
jberry
100+ Club
 
Posts: 144
Joined: Mon Mar 19, 2007 4:40 pm
Location: Atlantic City, NJ

Postby mwa103 on Mon Mar 19, 2007 5:58 pm

Also another work around I have found that seems to work well for centering content is instead of using left: 175px; (or any other set value), you can do:
Code: Select all
#center {
   position:absolute;
   left:50%;
   margin-left: -__px;
}

Fill in the blank with your page width / 2 (page width = 800 then put in -400). This moves all the content to the right with its left edge setting at center, then the negative left margin moves the content back to the left so that the center of the content is centered on the page. Not sure if this works in all browsers, but it does work in IE & FF for sure.

-Mike
mwa103
100+ Club
 
Posts: 206
Joined: Mon Mar 07, 2005 10:55 pm

Postby jberry on Mon Mar 19, 2007 7:10 pm

Another way to do it becasue using absolutes will mess things up if you change screen sizes so if you use this no matter what screen and if it is minimzed or not it will work
Code: Select all
#center {  width: 750px; text-align: center; margin: 0 auto;}
jberry
100+ Club
 
Posts: 144
Joined: Mon Mar 19, 2007 4:40 pm
Location: Atlantic City, NJ


Who is online

Users browsing this forum: No registered users and 0 guests