12 replies [Last post]
srgause
Offline
newbie
NYC
Last seen: 15 years 3 weeks ago
NYC
Joined: 2007-07-27
Posts: 6
Points: 0

Hi,

I'm trying to auto-center a webpage horizontally, but it's just not working. I've used the code snippets from the other threads here, and also from the Dead Centre page. I don't understand what I'm doing wrong!

The page is complicated, but I'm assigning div containers with the left and right margins to auto. I have specific spacing/margins for header/footer elements on the page... is that throwing everything off?

Thanks,
Suzanne

lokiloks
lokiloks's picture
Offline
Enthusiast
Albuquerque, NM
Last seen: 12 years 15 weeks ago
Albuquerque, NM
Timezone: GMT-6
Joined: 2007-05-16
Posts: 145
Points: 24

Everyone hates this

I know it's not popular, but google's designers agree with me. Use a center tag.

Put anything you want centered here.

I typically use css to center as well, just to be sure other browsers handle it.

Hope that helps

LokiLoks

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 31 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

lokiloks wrote:I know it's

lokiloks wrote:
I know it's not popular, but google's designers agree with me. Use a center tag.

Put anything you want centered here.

I typically use css to center as well, just to be sure other browsers handle it.

Hope that helps

LokiLoks
:curse:

Not acceptable!

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

wolfcry911
wolfcry911's picture
Offline
Guru
MA, USA
Last seen: 8 years 24 weeks ago
MA, USA
Timezone: GMT-5
Joined: 2004-09-01
Posts: 3224
Points: 237

suggesting the use of the

suggesting the use of the center tag certainly does not help. It's been deprecated and should not be used.

Auto margins must be used with an explicit width. Have you assigned a width to the container? A block level element will take up all available width by default, so there is nothing to center unless you set the width.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 31 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

srgause wrote:Hi, I'm

srgause wrote:
Hi,

I'm trying to auto-center a webpage horizontally, but it's just not working. I've used the code snippets from the other threads here, and also from the Dead Centre page. I don't understand what I'm doing wrong!

The page is complicated, but I'm assigning div containers with the left and right margins to auto. I have specific spacing/margins for header/footer elements on the page... is that throwing everything off?

Thanks,
Suzanne
:shrug:

Good on you for checking the 'how to' section but did you read posting guidelines? a little link or sight of code is always asked for, then we might be able to actually help you.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

srgause
Offline
newbie
NYC
Last seen: 15 years 3 weeks ago
NYC
Joined: 2007-07-27
Posts: 6
Points: 0

it's a private development

it's a private development site so you won't have access to view the link, and like I said, it's SUPER COMPLICATED. I'm sure I have a conflicting style somewhere... when I set margin: auto everything aligns left. Actually, everything I do aligns the content left, unless when I specify specific left and right percentages. But no left-align or left margins are in place (that I can see)

This is probably not the right place to ask questions, but I'm so stuck and just can't do anything else!!!

srgause
Offline
newbie
NYC
Last seen: 15 years 3 weeks ago
NYC
Joined: 2007-07-27
Posts: 6
Points: 0

oh, and yes i have the width

oh, and yes i have the width set to 750px
this is what i have so far and it's fake-centering when the browser is fully expanded
body { margin: 0px;}
#page-wrapper {position:absolute; top:5%; left: 11%; right: 10%; width:100%;}

srgause
Offline
newbie
NYC
Last seen: 15 years 3 weeks ago
NYC
Joined: 2007-07-27
Posts: 6
Points: 0

oh, and yes i have the width

oh, and yes i have the width set to 750px
this is what i have so far and it's fake-centering when the browser is fully expanded
body { margin: 0px;}
#page-wrapper {position:absolute; top:5%; left: 11%; right: 10%; width:100%;}

srgause
Offline
newbie
NYC
Last seen: 15 years 3 weeks ago
NYC
Joined: 2007-07-27
Posts: 6
Points: 0

oh, and yes i have the width

oh, and yes i have the width set to 750px
this is what i have so far and it's fake-centering when the browser is fully expanded
body { margin: 0px;}
#page-wrapper {position:absolute; top:5%; left: 11%; right: 10%; width:100%;}

srgause
Offline
newbie
NYC
Last seen: 15 years 3 weeks ago
NYC
Joined: 2007-07-27
Posts: 6
Points: 0

oh, and yes i have the width

oh, and yes i have the width set to 750px
this is what i have so far and it's fake-centering when the browser is fully expanded
body { margin: 0px;}
#page-wrapper {position:absolute; top:5%; left: 11%; right: 10%; width:100%;}

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 7 years 31 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Hmm SUPER COMPLICATED not

Hmm SUPER COMPLICATED not sure what that means except that it generally will tend to mean incorrect (no offence intended) CSS layouts are not generally super complicated however without sight of anything we are not really in a position to be able to help you are we?

How about posting the code?

edit/ x-posted with above, but super complicated begins to make sense, all code is helpful, within code tags, however position absolute is not going to make matters simple

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

thepineapplehead
thepineapplehead's picture
Offline
Moderator
Last seen: 15 weeks 6 days ago
Timezone: GMT+1
Joined: 2004-06-30
Posts: 9683
Points: 819

Why on earth are you using

Why on earth are you using absolute positioning?

Verschwindende wrote:
  • CSS doesn't make pies

wolfcry911
wolfcry911's picture
Offline
Guru
MA, USA
Last seen: 8 years 24 weeks ago
MA, USA
Timezone: GMT-5
Joined: 2004-09-01
Posts: 3224
Points: 237

thepineapplehead wrote:Why

thepineapplehead wrote:
Why on earth are you using absolute positioning?

it's super complicated Wink