XHTMLboy Posted September 17, 2010 Share Posted September 17, 2010 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 Link to comment Share on other sites More sharing options...
ShadowMage Posted September 17, 2010 Share Posted September 17, 2010 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. Link to comment Share on other sites More sharing options...
XHTMLboy Posted September 17, 2010 Author Share Posted September 17, 2010 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 Link to comment Share on other sites More sharing options...
justsomeguy Posted September 17, 2010 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. Link to comment Share on other sites More sharing options...
jeffman Posted September 17, 2010 Share Posted September 17, 2010 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 Link to comment Share on other sites More sharing options...
thescientist Posted September 17, 2010 Share Posted September 17, 2010 it just does. Link to comment Share on other sites More sharing options...
jeffman Posted September 17, 2010 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. Link to comment Share on other sites More sharing options...
thescientist Posted September 17, 2010 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. Link to comment Share on other sites More sharing options...
jeffman Posted September 17, 2010 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.