使用margin-left:auto;margin-right:auto; 可以让你的div居中对齐。
.style{margin-left:auto;margin-right:auto;}
缩写形式为:
.style{margin:0 auto;}
数字0 表示上下边距是0。可以按照需要设置成不同的值。
注意,需要加上上面的那句
才能生效,要是不想要这句的话,也可以给body加一个属性:
body{text-align:center;}
另外,让div内的内容(包括文字及图片)居中的代码是: text-align:center;
from : http://www.div-css.com/html/XHTML-CSS/QA/84092469777743.html