Must-see reference:
Http://www.jb51.net/css/28259.html
Align Div Center
The abbreviated form is:
. style{margin:0 Auto;}
The number 0 indicates that the top bottom margin is 0. Can be set to a different value as needed.
Example:
1 2<! DOCTYPE HTML Public"-//W3C//DTD XHTML 1.0 transitional//en" "HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD">3"http://www.w3.org/1999/xhtml"lang="ZH-CN">45<meta http-equiv="Content-type"Content="text/html; charset=gb2312"/>6<title> Center div Presentation Effect </title>7<style type="Text/css">8. align-center{9Margin0Auto/*centering this is necessary, and other properties are not required*/ Tenwidth:500px;/*to the width of the top to the browser on both sides of the center can not see the effect*/ Onebackground:red;/*Background Color*/ AText-align:center;/*text and other content centered*/ - } -</style> the -<body> -<divclass="Align-center"> Center div Presentation Effect </div> -</body> +You can also add a property to the body: body{text-align:center;}
In addition, the content within the DIV (including text and images) centered code is: text-align:center;
(Horizontal vertical center)
1<title> Horizontal Vertical Center div presentation Effect </title>2<style type="Text/css">3. align-center{4position:fixed; Left:%;top:2%;margin-left:width/; margin-top:height/ 2 ;5 } 6</style>78<body>9<divclass="Align-center"> Horizontal Vertical Center div presentation Effect </div>Ten</body> OneOk
"HTML" "10" div layout [div horizontal vertical Center]