1、一般情况下DIV居中失效是因为没写DTD语句
在页面的最上方加上:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
其实其他很多css的问题也是因为没有加上dtd语句引起的。
2、使用margin来让DIV居中
最简单的写法就是:
.divstyle{ margin:0 auto; }
1、一般情况下DIV居中失效是因为没写DTD语句
在页面的最上方加上:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
其实其他很多css的问题也是因为没有加上dtd语句引起的。
2、使用margin来让DIV居中
最简单的写法就是:
.divstyle{ margin:0 auto; }