css做的盒子为什么在IE中浏览的效果不同呢

来源:百度知道 编辑:UC知道 时间:2024/05/20 07:22:13
我用DIV+CSS设计页面布局,在FIRFOX中浏览正常,但在IE中浏览效果却不同,很苦恼,在下是菜鸟,请高手指点一下;主要问题是:我设置一个盒子居中,在IE中却无法完成;代码如下:
body
{
width:80%;
height:90%;
background-image:url("image/109.gif");
border:1px dashed blue;
margin:0 auto;
}
在表现上:margin:0 auto;这条语句在IE中始终无法将盒子定位在中间位置:
请高手讲解一下如何在多种浏览器中作出一样的效果来

楼主这么写代码
body{
text-align:center; /*其他属性忽略*/
}
.box{
width:80%;
height:90%;
background-image:url("image/109.gif");
border:1px dashed blue;
margin:0 auto;
}
恩 这样写目前常见的浏览器都能居中显示的
祝楼主好运!

要给出具体代码, 按你目前代码来看 是没问题的 margin:0 auto是正确的,

如果是在IE5.5以下 是要用 text-align:center来解决 ,IE6以上版本是没问

把你的margin:0 auto;
加到相应的box上就居中了··

给你做个例子你参考一下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<ti