/    Sign up×
Community /Pin to ProfileBookmark

Center WebPage with Absolute Positioned Divs

Hello,

I am having problems centering my web page. The images are contained in divs that are absolute positioned. I have tried numerous options with no success.

I currently have a background image with the page aligned to the left.

The address is:

[url]http://www.inv3.com/beta_v3site/v3_left_test.html[/url]

Any insight would be greatly appreciated.

to post a comment
CSS

5 Comments(s)

Copy linkTweet thisAlerts:
@BrettNooyenJan 02.2008 — Try adding a "position:relative;"

to your #container div.
Copy linkTweet thisAlerts:
@absolutmgd13Jan 02.2008 — making a wrapper is a good idea...also try:

margin-left:auto;

margin-right:auto;

thats usually how i do it.
Copy linkTweet thisAlerts:
@dtm32236Jan 02.2008 — margin-left:auto;

margin-right:auto;

can be written [B]margin: 0 auto;[/B]
Copy linkTweet thisAlerts:
@BrettNooyenJan 02.2008 — making a wrapper is a good idea...also try:

margin-left:auto;

margin-right:auto;

thats usually how i do it.[/QUOTE]


The OP does have a wrapper, which is #container. He has a margin: auto; which won't do top or bottom but it should take care of the centering.

I think the problem lies in the fact that everything he is doing inside of #container is via absolutely positioned items, and there is no relatively positioned parent to attach those divs to. Thus, the divs are attaching itself to the browser window and/or the html/body tag.

By setting #container as position:relative; the absolutely positioned divs should then nest themselves along the borders of that container.
Copy linkTweet thisAlerts:
@felgallJan 03.2008 — See http://www.felgall.com/cshow03.htm for a simple way to put something dead centre in the window.
×

Success!

Help @v3images 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 6.18,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...