How to center the div horizontally:
The use of the whole Div to center horizontally is fairly frequent. For example, a Web page is generally centered horizontally in the browser.
code example:
<!DOCTYPE HTML> <HTML> <Head> <MetaCharSet= "Utf-8"> <Metaname= "Author"content= "http://www.51texiao.cn/" /><title>Ant Tribe</title><styletype= "Text/css">. MyTest{width:200px;Height:200px;Border:1px solid Red;margin:0px Auto; } </style> </Head> <Body> <Divclass= "MyTest">Ant Tribe</Div> </Body> </HTML>
The above code implements this effect by centering the div horizontally, adding margin:0px auto to the object. Finally, add that if the div does not set the width value, margin:0px auto is invalid.
The original address is: http://www.51texiao.cn/div_cssjiaocheng/2015/0519/1896.html
The most original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=4704
How to center div horizontally