novicenate Posted February 23, 2007 Share Posted February 23, 2007 I want to have divisions centered on the page no matter if the screen is at 800x600 or 1280x1048 or whatever. I found the code to make it centered...margin:0 autobut when I put this in, the top margin comes down to about 4 pixels. What am I doing wrong? I want it to be flush with the top of the page.thanks Link to comment Share on other sites More sharing options...
jlhaslip Posted February 23, 2007 Share Posted February 23, 2007 First of all, I hope you had a semi-colon after that. It should be listed in the css code as : margin:0 auto; Notice the trailing semi-colon.And without seeing your page, would you happen to have a top text header up there? Remove the margins on those items as well. some Browsers stop the page from attaching to the very top if the contained element still has a margin. Use padding instead to force the header down to suit the layout.We might be able to assist you further if you post a link or the page code. thanks. Link to comment Share on other sites More sharing options...
roondog Posted February 23, 2007 Share Posted February 23, 2007 I findbody{margin: 0;}sorts it out Link to comment Share on other sites More sharing options...
croatiankid Posted February 23, 2007 Share Posted February 23, 2007 put padding:0 for it too, since opera adds padding to BODY Link to comment Share on other sites More sharing options...
MrAdam Posted February 23, 2007 Share Posted February 23, 2007 i use: body{ margin: 0px; padding: 0px;}div.wrapper /*(or something)*/{ margin: 0px auto;} works everytime for me. Link to comment Share on other sites More sharing options...
aspnetguy Posted February 23, 2007 Share Posted February 23, 2007 depending on your doctype this will not work in IEI always do this so I never have to worry about the doctype body{ margin: 0px; padding: 0px; text-align: center;}div.wrapper /*(or something)*/{ width: 800px; margin: 0px auto; text-align: left;} BTW you need to give the div a width inorder to center it else it is already taking 100% width. Link to comment Share on other sites More sharing options...
croatiankid Posted February 23, 2007 Share Posted February 23, 2007 I always use a full absolute URL doctype so browsers are in standards mode and I don't have to worry about quirks. Link to comment Share on other sites More sharing options...
aspnetguy Posted February 23, 2007 Share Posted February 23, 2007 %99.9 of the time I do to, I use XHTML 1.0 strict but sometimes I am forced to downgrade the doctype due to client needs (or due to horrible third-party code) and then some CSS behaves different in IE.Sometimes you just can't have the ideal situation. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now