IE6中背景图像不居中

时间:2010-09-15 14:15:12

标签: html css internet-explorer

我正在尝试使用中心对齐的正文背景图像,但它在IE 6中不起作用。正文的CSS是

body{line-height: 160%;font-family: "Trebuchet MS", sans-serif; font-size: 80%; 

/*     background: #000a28 url('img/main_bg.png') no-repeat center top;*/
background-image:url('img/main_bg.png');
background-repeat:no-repeat;
background-attachment:scroll;
background-position:center top;
background-color: #000a28;
width: 100%;
margin: 0 auto;
color: #ffffff;
text-align: center!important}

对于IE 6,我编写了以下CSS

body {
  text-align:center;
}

#main-wrapper {
  margin:0 auto;
  width:960px;
  text-align:left;
}

请帮帮我。

2 个答案:

答案 0 :(得分:2)

它无法正常工作的原因是您正在使用的SuperSleight透明png脚本。因为脚本仅在加载完所有内容后运行,所以后台首先居中,然后在脚本运行时跳回到左侧。据我所知,AlphaImageLoader不允许更改背景位置。

请尝试使用此脚本:http://www.dillerdesign.com/experiment/DD_belatedPNG/。它使用不同的解决方案,允许使用背景位置。

答案 1 :(得分:0)

尝试使用我的代码而不是身体的属性

body{
background:url('img/main_bg.png') #000a28 no-repeat center top;
color: #ffffff;
font-family: "Trebuchet MS", sans-serif; 
font-size: 80%;
line-height: 160%;
text-align: center;
}