July 13, 200917 yr Hi I was wondering how do you centre a div using css style horizontally and vertically ? I have been trying and trying I can get it one way but not the other any help ?
July 14, 200917 yr If that doesn't work, then your next option is to use negative margins and absolute positioning. For example, if you had a 480 x 230 box, you would use the following code: #center { width:480px; height:230px; position:absolute; left:50%; top:50%; margin-left:-240px; margin-top:-115px; } That would then be centralised, the negative margins always have to be half of the total width or height.
July 14, 200917 yr Author If that doesn't work, then your next option is to use negative margins and absolute positioning. For example, if you had a 480 x 230 box, you would use the following code: #center { width:480px; height:230px; position:absolute; left:50%; top:50%; margin-left:-240px; margin-top:-115px; } That would then be centralised, the negative margins always have to be half of the total width or height. Thank you Traxor
Create an account or sign in to comment