deejaybet Posted December 6, 2005 Share Posted December 6, 2005 some browsers like firefox pick up text-align: center on sum of the site but other parts of the site it ignores Link to comment Share on other sites More sharing options...
Jonas Posted December 6, 2005 Share Posted December 6, 2005 Hmm... My guess is that you use text-align: center in for example your body tag, to center a page? The way to center for example a div isn't to put text-align: center in the containing element. Instead, put in the (in this example) div:margin: auto;It's IE that uses the text-align: center wrongly. As it implies, it is to be used for text, and text only. Non-formatted, raw text. Link to comment Share on other sites More sharing options...
deejaybet Posted December 6, 2005 Author Share Posted December 6, 2005 ok you have just onfused me lol... the site works perfectly as it should in IE.. centered were is shoudl etc... but if i view it on other browsers say for example firefox... the site has some elements... mainly text aligned correctly but the page(s) go to the default setting (left side) Link to comment Share on other sites More sharing options...
Jonas Posted December 6, 2005 Share Posted December 6, 2005 Ok, put it like this: STYLESHEETbody {text-align: center}HTML<body><div>Text here...</div></body> That code will display a div in the center of the page, but only in IE, because the propertytext-align: center;is only meant to work on raw text within an element. Like if you had put text-align: center in a div { } in your css, it would display the text in the div centered within the div. To make elements align, you're actually not supposed to give the container element, in this case <body>, a value of text-align: center, but rather give the element itself a margin. But, for it to work in IE again, you need both... STYLESHEETbody {text-align: center;}div {margin: auto;}HTML<body><div>Text here...</div></body> That will work for all browsers, standards-compliant ones as well as IE.I could have just told you to put margin: auto in your css within the element you wanted to center, but I felt like explaining why text-align: center on elements only works in IE... Link to comment Share on other sites More sharing options...
deejaybet Posted December 6, 2005 Author Share Posted December 6, 2005 so whats the margin: auto do ? does that make the pages center when i have the text-center in body {} in firefox and opera Link to comment Share on other sites More sharing options...
Jonas Posted December 6, 2005 Share Posted December 6, 2005 margin: auto sets the same margin on the left and right side of the element, so yeah, it will display centered. IE needs body {text-align: center} to align the text centered. But margin: auto is the way it's supposed to be done. Microsoft just hasn't caught up with that yet. Link to comment Share on other sites More sharing options...
deejaybet Posted December 6, 2005 Author Share Posted December 6, 2005 slight problem i found with the margin thing.. ive got margin: 0px; in my body so the site is at the top of the browser and fits perfectly so that wont really work... maybe i should just use <center></center> tags in the html Link to comment Share on other sites More sharing options...
Jonas Posted December 6, 2005 Share Posted December 6, 2005 No.body {margin: 0px;}will make your body stretch to the full browserwindow. It has nothing to do with displaying the other stuff.div {margin: auto;}p {margin: auto;}table, tr, td {margin: auto;}whatever {margin: auto;}does not interfere with your body's margins... Link to comment Share on other sites More sharing options...
deejaybet Posted December 6, 2005 Author Share Posted December 6, 2005 hmm aw well doesnt work anyway lol.. thanks for tryin to help me anyhow lol Link to comment Share on other sites More sharing options...
Jonas Posted December 6, 2005 Share Posted December 6, 2005 Can you give me your code or a link to your site so I can see for myself? Link to comment Share on other sites More sharing options...
Skemcin Posted December 6, 2005 Share Posted December 6, 2005 That will work for all browsers, standards-compliant ones as well as IE. sorry, I just have to say I LOVE this remark! Link to comment Share on other sites More sharing options...
deejaybet Posted December 6, 2005 Author Share Posted December 6, 2005 oookkk.... you feeling alright there skemcin haha Link to comment Share on other sites More sharing options...
tuffrabit Posted December 7, 2005 Share Posted December 7, 2005 use the negative margin theory:set the left of an element at 50%set that elements left margin at its negative halfexample:#container {position:absolute;width:500px;left:50%;margin-left:-250px;}that centers the mess out of anything. =) enjoy Link to comment Share on other sites More sharing options...
deejaybet Posted December 7, 2005 Author Share Posted December 7, 2005 but wat about ppl with big screens will it not be dodgy lookin lolill just stick with the <center></center> tags.. dnt need to change the centering in my style sheets anyway Link to comment Share on other sites More sharing options...
tuffrabit Posted December 8, 2005 Share Posted December 8, 2005 use percentiges instead of absolute pixel values. =)#container {position:absolute;width:80%;left:50%;margin-left:-40%;}that works great too. 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