【问题标题】:Background image is not in centered in IE6背景图像不在 IE6 中居中
【发布时间】:2010-09-15 23:10:20
【问题描述】:

我正在尝试使用居中对齐的正文背景图像,但它在 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;
}

请帮帮我。

【问题讨论】:

    标签: html css internet-explorer


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      试试我的代码而不是你身体的属性

      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;
      }
      

      【讨论】:

      • 不,它仍然无法正常工作,在重新加载时显示图像位于中心,但当页面加载时,它返回左对齐。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-20
      • 2016-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-08
      相关资源
      最近更新 更多