Tynian Posted March 3, 2006 Share Posted March 3, 2006 Hi ! I've a little problem.I just want to center a <div> </div> in my css, on Internet explorer.I arrived to do that with Firefox, but none also on internet explorer, can you help me please. Link to comment Share on other sites More sharing options...
boen_robot Posted March 3, 2006 Share Posted March 3, 2006 margin: 0 auto; or text-align: center; didn't worked? Link to comment Share on other sites More sharing options...
Tynian Posted March 3, 2006 Author Share Posted March 3, 2006 margin: 0 auto; or text-align: center; didn't worked? <{POST_SNAPBACK}> The first one works well on firefox, but not on internet explorer, that the problem.in fact, I just want to include all the programmation code in a div and center it on my page, for the resolution.and the second, I think it would'nt work, becaouse I don't want to center text only. Link to comment Share on other sites More sharing options...
raimo Posted March 3, 2006 Share Posted March 3, 2006 The first one works well on firefox, but not on internet explorer, that the problem.in fact, I just want to include all the programmation code in a div and center it on my page, for the resolution.and the second, I think it would'nt work, becaouse I don't want to center text only.<{POST_SNAPBACK}> for all browsers:body{text-align: center; /* MSIE needs this */}#container{margin: 0 auto;width: 750px;text-align: left;} so div with ID "container" is now centered with all browsers..as far as I know, there is no other way to do it with MSIE. Link to comment Share on other sites More sharing options...
Tynian Posted March 3, 2006 Author Share Posted March 3, 2006 Noway, I find a soluce.I've used another solution : #page { position: absolute; left: 50%; width: 500px; margin-left: -250px; margin-top: 30px; }and it works both. thanks Link to comment Share on other sites More sharing options...
Err Posted March 5, 2006 Share Posted March 5, 2006 This should also work also: #page { margin-left: auto; margin-right: auto;} Please note that you need any DTD on your webpages for this to work on IE. Firefox displays this correctly. Link to comment Share on other sites More sharing options...
raimo Posted March 5, 2006 Share Posted March 5, 2006 Please note that you need any DTD on your webpages for this to work on IE. Firefox displays this correctly.Seems as it works very well, but only if strict DTD is used with IE..But who is using transitional anyway? Link to comment Share on other sites More sharing options...
Err Posted March 5, 2006 Share Posted March 5, 2006 Seems as it works very well, but only if strict DTD is used with IE..But who is using transitional anyway? <{POST_SNAPBACK}> I worked for me whenever I used it on a XHTML Transitional DTD page, so I assumed that it would work on all other DTDs. Link to comment Share on other sites More sharing options...
Jonas Posted March 7, 2006 Share Posted March 7, 2006 http://flumpcakes.co.uk/css/center-div-ie Link to comment Share on other sites More sharing options...
Tynian Posted March 7, 2006 Author Share Posted March 7, 2006 Why does'nt it work well on both browser with the same code.now I've problem with margin, that does'nt look the same Link to comment Share on other sites More sharing options...
raimo Posted March 8, 2006 Share Posted March 8, 2006 Reasons why and why not can be found in MSDN:Read The !DOCTYPE "Switch" part:http://msdn.microsoft.com/library/default....nhancements.asp :)edit:If You are using HTML transitional or frameset doctype You must use it with URL-part of DTD-tag to switch IE to "standard-compliant" mode.When Internet Explorer 6 or later is not in standards-compliant mode, it is in compatibility mode.DTD to switch IE better mode is:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">now margin: 0px auto; will work with IE6 without centering all in body-element. Link to comment Share on other sites More sharing options...
Tynian Posted March 8, 2006 Author Share Posted March 8, 2006 Reasons why and why not can be found in MSDN:Read The !DOCTYPE "Switch" part:http://msdn.microsoft.com/library/default....nhancements.asp <{POST_SNAPBACK}> Thanks sure that's solve my problèm 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