+ -
当前位置:首页 → 问答吧 → IE6 css背景图问题

IE6 css背景图问题

时间:2011-04-21

来源:互联网

<div id="mydiv" class="o">11111</div>
CSS代码如下,在IE6/7/8、FF等其他N个浏览器下均正常,唯IE6下显示背景为a.png,而非b.png.
CSS code

#mydiv {BACKGROUND: url(../images/a.png) no-repeat center center;}
#mydiv.o {BACKGROUND: url(../images/b.png) no-repeat center center;}

标准是<!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">。
请高手指教。

作者: justcode   发布时间: 2011-04-21

注意,png图都不是透明的,IETester debug工具条分析出来的Comp.Style是BACKGROUND: url("http://localhost/images/a.png") no-repeat...

作者: justcode   发布时间: 2011-04-21

1)迁就下ie6吧
2)你这个css的选择方法 总感觉很拗口 id不是代表唯一的元素吗 既然是唯一的元素 在分个类 貌似感觉怪怪的
如果一个id下面分多个类的话 我情愿在嵌套个层次 


#mydiv {}
#mydiv .o {BACKGROUND: url(../images/b.png) no-repeat center center;}
#mydiv .o1 {BACKGROUND: url(../images/a.png) no-repeat center center;}


<div id='mydiv'>
  <div id='o'></div>
  <div id='o1'></div>
</div>

作者: KK3K2005   发布时间: 2011-04-21

<div id='mydiv'>
  <div class='o'></div>
  <div class='o1'></div>
</div>

前面段写错了 应该是class

作者: KK3K2005   发布时间: 2011-04-21

#mydiv.o ie6不支持

作者: ddcatlee   发布时间: 2011-04-21

测试没有发现问题,#mydiv.o 中间有空格吧 #mydiv .o。

作者: tan0998   发布时间: 2011-04-21

奇怪了,我这里怎么支持呢

<div id ="mydiv" > 

<div class="o"></div>
</div>



#mydiv {BACKGROUND: url(download.png) no-repeat center center; height:140px; width:80px;}
#mydiv .o {BACKGROUND: url(apple.png) no-repeat center center; height:70px; width:80px;}

作者: tan0998   发布时间: 2011-04-21

热门下载

更多