XHTMLboy 4 Posted September 17, 2010 Report Share Posted September 17, 2010 (edited) 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 September 17, 2010 by XHTMLboy Quote Link to post Share on other sites
ShadowMage 94 Posted September 17, 2010 Report Share Posted September 17, 2010 (edited) 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 September 17, 2010 by ShadowMage Quote Link to post Share on other sites
XHTMLboy 4 Posted September 17, 2010 Author Report Share Posted September 17, 2010 (edited) 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 September 17, 2010 by XHTMLboy Quote Link to post Share on other sites
justsomeguy 1,135 Posted September 17, 2010 Report Share Posted September 17, 2010 The left and right margins are set to half of the difference in width between the element and its container. If the container is 1000px, and the element is 500px, then the difference is 500 and each margin is 250. Quote Link to post Share on other sites
jeffman 86 Posted September 17, 2010 Report Share Posted September 17, 2010 (edited) 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 September 17, 2010 by Deirdre's Dad Quote Link to post Share on other sites
thescientist 231 Posted September 17, 2010 Report Share Posted September 17, 2010 it just does. Quote Link to post Share on other sites
jeffman 86 Posted September 17, 2010 Report Share Posted September 17, 2010 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. Quote Link to post Share on other sites
thescientist 231 Posted September 17, 2010 Report Share Posted September 17, 2010 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. Quote Link to post Share on other sites
jeffman 86 Posted September 17, 2010 Report Share Posted September 17, 2010 No, no. I was saying I feel the same way most of the time. Just that I also appreciate having a forum that makes me remember stuff. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.