/    Sign up×
Community /Pin to ProfileBookmark

Safely centering absolute divs

Hello,

I am just wondering if there is a good way to center absolute divs in a page. [url]www.degreethree.com/newsite.[/url] Some of the elements are positioned on top of others.

Is there a sort of element which will act as the root for all of those positionings so that I can center it all? I don’t want to use frames.

Thanks,
Ian

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@David_HarrisonApr 20.2004 — What is the point of using CSS if you then go and use tables for layout and center and font tags for presentation?

To centre a block level element you can simply add style="margin:0 auto" to it, the margins on either side will expand as much as they can and the element will be "pushed" into the middle of whatever containing element they are in.

This works only for elements with a defined width, and I suggest you give the div a width because there is a gap on the right hand side of your content in Mozilla Firefox that creates a horizontal scrollbar.

Don't have Mozilla? [url=http://www.mozilla.org/]Go get it.[/url]
×

Success!

Help @freefall 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.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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