2012-07-22 56 views
0

使用下面的代码,我在IE7到IE9的背景图像周围得到一个边框。为什么?为什么即使边框设置为无,图像在IE中仍然有边框?

<tr> 
    <td class="wishes"> 
     <a class="clickable"> 
      <img class="alreadyWished" border="0" width="19" height="16" 
       alt="Already Wished"/><br /> 
      Already Wished 
     </a> 
    </td> 
</tr> 

<style> 
.clickable 
{ 
    outline:none; 
    cursor:pointer; 
    border:none; 
} 

.wish 
{ 
    background-image:url(../images/wished.jpg); 
    background-repeat:no-repeat; 
    border:none; 
    outline:none; 
} 

.alreadyWished 
{ 
    background-image:url(../images/alreadyWished.jpg); 
    background-repeat:no-repeat; 
    border:none; 
    outline:none; 
} 
</style> 

回答

0

这对我来说有点奇怪。 为什么不在.clickable上使用不同的类,并避免使用没有“src”的“img”。

看看我做什么,你可能需要使用一些JS的用类来代替阶级“.wish”“.alreadyWished”

<tr> 
<td class="wishes"> 
    <a class="clickable .wish"></a> 
</td> 

.clickable.wish { background:url("wished.jpg") no-repeat center left; padding-left:25px; /* padding equal to your width of the background image + 10-15px */} 
.clickable.alreadyWished { background:url("alreadyWished.jpg") no-repeat center left; padding-left:25px; /* padding equal to your width of the background image + 10-15px */} 
0

在CSS中,border不接受'none'的值。将其设置为0.原因是,边界属性的存在表明存在边界,因此说'无'是没有意义的。

另外,HTML中没有属性'img'的边框。

1

这是IE中的错误。 CSS的specs say

8.5.3边框样式

...

没有
无边框;计算出的边界宽度为零。

IE不关心。您需要额外设置border-width: 0。 (或border: 0 none;),如果你想使用组合名称。