DIV绝对居中
下面是源代码:
<html><head><style type="text/css">/*居中层CSS,定位页面中央的一点*/#center{background:#111111;height:400px;width:300px;/*设置位置*/top:50%;left:50%;position:absolute;color:#ffcccc;}/*内容层CSS,根据中央的一点确定自己的位置*/#content{background:#D0DEED;width:300px;height:200px;/*设置浮动,脱离居中层限制(菜单什么很有用哦)*/position:absolute;/*上右下左的边距,这里设置的2个值,第一个是高,第二个是宽,但都是这个DIV的宽高的一半*/margin:-100px 0 0 -150px;/*演示用*/color:#111111;}/*以上两个从http://www.cccbbs.net/htm_data/36/0811/28798.html看到的,进行了一定的修正*//*以上两个的合并,只要调用这一个CLASS就OK了*/#test_center{width: 340px;height: 140px;left: 50%; top:50%;margin-left:-170px;margin-top: -70px; position: absolute;background:#BBBBBB;}</style></head><body><div id="center"><div id="content"></div></div><div id="test_center"></div></body></html>