/    Sign up×
Community /Pin to ProfileBookmark

align my site to the center

I made a site layout using DIV tags.

i use the absolute and then added left and top apps to line it all up.

now i want to center my site.

how do i do that?

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@pyroNov 10.2003 — Put a container div around it all, and use margin: auto; for complaint browsers, and text-align: center; (around the parent of you container tag -- probably the <body> tag) for IE 5.
Copy linkTweet thisAlerts:
@bobmurphyNov 12.2003 — i got a page to centre in both planes ( X&Y) by putting everything in a div and giving the div the following style

div {position:absolute; height:420px; width:770px; top:50%; left:50%; margin:-210px 0px 0px -385px}

those dimensions work for anything from 600*800 up to pretty big - but it goes nuts in version 4 browsers and opera 5.02 - so i used the php function -> preg_match to provide opera with a different style


there are also some pretty good pages on the net that major on centering -- it's worthwhile doing a search

you can see the effect on my site ( still under development ) at www.oneweekofdays.com/biog
×

Success!

Help @chris9902 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...