Hi all, My class won't center on my page, it just stays at the left? Can anyone see a problem. Thanks This is my code, I've declared in the overall body: width: 1260px; /*silly width, not 800-friendly yet still small on the next screensize up... might as well go to 960 or something*/ margin: 0 auto; .float { position: absolute; width: 800px; margin: 0 auto; margin-top: 90px; color: black; font-style: italic; font-family: times; font-size: 4.5em; }
Didn't see that you were using absolute positioning. left:50%; margin-left:-400px; Code (markup): the value of margin-left just needs to be half of your width.
Devitor - No access to computer that has the files on it for a couple of days - I don't understand this at all? left:50%; margin-left:-400px; Code (markup): Or what you mean heloraghu? Thanks
since you have absolute positioning on by using 'left:50%' you are placing the div's left side in the center of the screen. You use 'margin-left: -400px;' to set your margin to go to the left negative 400 pixels which is half of what you total width is, this should place the center of your div in the center of the screen. Here is an example using the same class you posted originally
Just take out the absolute positioning margin: 0 auto; is the part that centers it but you are also using a class why not a div or both? #float { width: 800px; margin: 0 auto; margin-top: 90px; } .style { color: black; font-style: italic; font-family: times; font-size: 4.5em; } <div id="float" class="style"></div> Code (markup):
try doing... <div align="center"> <div class="float"> bla bla bla </div> </div> its certainly not the best practice but should work ..
I rebuilt the entire page. I've a new problem which I'm starting a new thread with. Thanks for your help ",)