简体   繁体   English

html / css - 使用sprite <img> 标签 - 如何删除Chrome中的大纲?

[英]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. 我正在重做一个我正在使用CSS精灵的网站。 I'm also using the sprite with some tags, which I cannot remove. 我也使用sprite和一些标签,我无法删除。

So the tag gets a CSS-background-image and appropriate background position. 因此标签获得CSS背景图像和适当的背景位置。 Works fine. 工作正常。 I had to remove the alt-attribute, because this kept showing on Firefox. 我不得不删除alt属性,因为这一直在Firefox上显示。 Not nice, but ok. 不好,但还可以。

My problem: In Chrome I end up having a faint outline around the image. 我的问题:在Chrome中我最终在图像周围有一个模糊的轮廓。 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; 如果我CSS outline: 3px solid blue的微弱边框,变成3px纯蓝色...但如果我设置outline: 0; nothing happens. 什么都没发生。

More code: HTML 更多代码:HTML

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

CSS 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. 通常这是由border属性引起的。 I know you said you think it's outline, but did you try this in your img class... 我知道你说你认为这是大纲,但你是否在你的img课程中尝试过这个...

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

or this 或这个

.imgClass
{
border:0;
}

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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