日期:2014-05-17  浏览次数:20579 次

div背景消失

我有3个div
<table width="900" border="0" cellpadding="0" cellspacing="0" style="border-spacing:0px;">
<tr>
<td style="width:300px">
<div id="tab1" class="tab1selected tab_buttons"></div>
</td>
<td style="width:300px">
<div id="tab2" class="tab2unselected tab_buttons"></div>
</td>
<td style="width:300px">
<div id="tab3" class="tab3unselected tab_buttons"></div>
</td>
</tr>
</table>
这3个div在select,unselect和hover时都有背景图片
id=tab3的div在hover时背景消失
css:
.tab3selected {
width: 270px;
height: 60px;
background: url(../images/detail_itinerary_inclusion_hover.jpg) no-repeat;
}
.tab3unselected {
width: 270px;
height: 60px;
background: url(../images/detail_itinerary_inclusion.jpg) no-repeat;
}
.tab3unselected:hover {
background: url(../images/detail_itinerary_inclusion_hover.png) no-repeat;
}
这3个div是一样设置的,只有第3个有问题
css div

------解决方案--------------------
把高度和宽度加上就有了
width: 270px;
height: 60px;
------解决方案--------------------
先问一下你是用个的IE6吗?

 :hover 当你鼠标经过这个div时,背景色和边框都会发生变化,但是此效果在IE6中不能得到效果,
因为IE6不支持hover伪类。在上面CSS样式中:hover 是给非IE浏览器识别的,因为大多数非IE浏览器都已经支持任意标记的hover伪类了。.hover是给IE6以及以下版本识别的,因为IE6以及一下版本一直都只支持<A href="">标记的hover伪类(IE7已支持任意标记hover伪类效果)。


------解决方案--------------------
div里 没有内容 是不是?那就给添加属性 让他拥有布局吧,不如 会上下外边距发生叠加,成为一条线,当然不会有图片显示了 。如何让他拥有布局,很多方式:设置 width,height,display:block,float等属性都可以
------解决方案--------------------
细心点嘛,先看看图片能不能访问
------解决方案--------------------
引用:
其实我犯了个愚蠢的错误,查了半天,文件名不对,谢谢各位

既然问题解决,建议楼主结贴