Jump to content

How does margin 0 auto work?


XHTMLboy
 Share

Recommended Posts

Hi all, i just want to know what "margin: 0 auto;" does, all i know is that it's used for centering things. And i know the zero in "margin: 0 auto;" mean's the TOP and BOTTOM. But what does the auto do. What properties does the auto give to the browser to center things? Help would be apperceated as it's on my mind all the time and it's agrivating me now. And sorry for the crap spelling :)

Edited by XHTMLboy
Link to comment
Share on other sites

I believe thescientist explained that in your other thread....The auto just tells the browser to split up the available space evenly between the left and right side of the element. By available space, I mean any unoccupied horizontal space between the left and right edges of the parent container.

Edited by ShadowMage
Link to comment
Share on other sites

I believe thescientist explained that in your other thread....The auto just tells the browser to split up the available space evenly between the left and right side of the element. By available space, I mean any unoccupied horizontal space between the left and right edges of the parent container.
Oooh ok i just didn't see the other post so i posted this one before the other post :L, But i get the margin: 0 auto; now thankyou :) Edited by XHTMLboy
Link to comment
Share on other sites

Shadow explained that, but I'll add some more. The browser subtracts the width of the element from the available space and divides it in two. Half goes to the right margin, half to the left margin.EDIT: :) to jsg

Edited by Deirdre's Dad
Link to comment
Share on other sites

it just does.
Realistically, after you've been developing a while, some things become so automatic that "it just does" is the mindset you live in. One of the reasons I like coming here is that I'm constantly being reminded why a technique does what it does, which is useful on those occasions when it breaks and I need to know how to fix it.
Link to comment
Share on other sites

i know, i didn't mean to come off as overly sarcastic, even though i did answer the question in his other thread. it's been a heck of long week for me and looks to be a longer weekend. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...