Well, in most of the scenarios in a web designing art, you might come across one wherein you have to center align a div tag, without affecting the text in it. Your first thought might be text-align:center; Of course it will work in all browsers, except that it leaves your text with a center alignment, as you can see below:
Hello
But if you want to center align the div alone, leaving the text alignment to be unaffected, you can use this trick css styling. Just give the margin of the div as : margin:0 auto; Lol... done. See below the effect.
Hello
Thats it... you can now center align a div without affecting the text-alignment of the div contents.
Copyright © 2009 Aackose Mentu Lal
Best Viewed in 1024 x 768 Resolution
No comments:
Post a Comment