日期:2014-05-17  浏览次数:20779 次

问个简单的CSS问题
描述如下:
1、页面采用背景图,如何让这个背景图在页面居中(上下 左右均居中)?

2、页面中只有一个div,如何让这个div在页面居中(上下 左右均剧中)?
css div

------解决方案--------------------
body {TEXT-ALIGN: center;}
 #center {
 MARGIN-RIGHT: auto;
 MARGIN-LEFT: auto; 
}
------解决方案--------------------
背景居中 body中  background:url(xxx.jpg) no-repeat center middle

div 水平居中  <div style='margin:0 auto'>

垂直居中有点困难 一般需要js配合获取网页显示高度 然后计算 margin-top值