CSS居中兼容火狐问题..

来源:百度知道 编辑:UC知道 时间:2024/05/26 18:57:48
我用ie8浏览就完美,用火狐或者Opera就错位了..
浏览地址是:http://hacksb.host235.ftp18.cn/
我用http://www.notfound.cn/HB6H057.html调用...
大家帮帮忙...
div#MainBody {
position: absolute;
left: 50%;
top: 50%;
margin-left: -478px;
margin-top: -235px;
text-align: center;
width: 855px;
height: 650px;
border: 1px #DDDDDD solid;
}
1楼的加上去错的更厉害.....

我刚才检查了你的网站,其实网站居中用 margin:0 auto; 就可以了,margin-left:0px;那就居左了,

第一,从你网站html code里看 id为 MainBody 的div 缺少了 </div> 结束标识符!
MainBody这div 没有包含全部网页内容, 导致你的div#MainBody { 设置甚至无效;

第二,你的网站在<link rel="stylesheet" rev="stylesheet" href="http://hacksb.host235.ftp18.cn/themes/default/source/style.css.asp" type="text/css" media="screen" />有设置MainBody布局位置,故但从div#MainBody {设置是不够的, 多一步一div检查下网站结构吧,可以用肢解的调试方法调试你的网站,希望我的回答能给你帮助!

数学没有学好啊,
margin-left: -478px; 这里应该是-428px

你的是水平垂直都居中。如果只要垂直居中就不用这么麻烦
div#MainBody {
margin:0 auto;
text-align: center;
width: 855px;
height: 650px;
border: 1px #DDDDDD solid;
}

margin-left:auto;margin-right:auto;
这才是兼容的居中,text-align:center;只有在IE下有用。
又没叫你直接加上去。

M我