简体   繁体   中英

Background image is not in centered in IE6

I am trying to use a body background image which is center aligned, but it does not work in IE 6. The CSS for the body is

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}

For IE 6 I wrote the following CSS

body {
  text-align:center;
}

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

Please help me.

The reason why it's not working is because of the SuperSleight transparent png script you are using. Because the script runs only after everything's loaded, the background first centers, then jumps back to the left when the script runs. As far as I'm aware, AlphaImageLoader does not allow for background position to be changed.

Try using this script instead: http://www.dillerdesign.com/experiment/DD_belatedPNG/ . It uses a different solution which should allow for background-position to be used.

Try my code instead of your body's properties

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM