简体   繁体   中英

html/css - using sprite with <img> tag - how to remove the outline in Chrome?

I'm redoing a site in which I'm using a CSS sprite. I'm also using the sprite with some tags, which I cannot remove.

So the tag gets a CSS-background-image and appropriate background position. Works fine. I had to remove the alt-attribute, because this kept showing on Firefox. Not nice, but ok.

My problem: In Chrome I end up having a faint outline around the image. I first thought these were border, but I think it's outline.

If I CSS outline: 3px solid blue the faint border, becomes 3px solid blue... but if I set outline: 0; nothing happens.

More code: HTML

<img class="ui-li-icon ui-li-thumb iconComments" />

CSS

.ui-icon, .iconComments, .iconMail, .ui-icon-searchfield:after {
    background:  #FFFFFF  /*{global-icon-color}*/;
    background:  transparent  /*{global-icon-disc}*/;
    background-image:  url(img/sprite.png)  /*{global-icon-set}*/;
    background-repeat: no-repeat;
    -moz-border-radius:  9px;
    -webkit-border-radius: 9px;
    border-radius: 9px;
    } 
.iconComments {
background-position:    -36px 50%;
    }
.iconMail {
background-position:     2px 50%;
    }
.iconComments, .iconMail {
height: 20px; 
width: 20px;
    }

Any idea, where the outline/border is coming from and how to remove it?

Thanks

问题可能是由于您的图像标记中没有src属性。

Usually this is caused by the border attribute. I know you said you think it's outline, but did you try this in your img class...

.imgClass
{ 
border-style: none; 
text-decoration: none; 
} 

or this

.imgClass
{
border:0;
}

如果您可以绝对定位图像,则可以使用CSS clip属性直接在前景中使用精灵。

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