Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove border around sprite image in Chrome

Tags:

First time using this technique, seems that regardless what attributes I try to assign the border will not go away in Chrome. Other browsers are fine. I've tried outline:none, border:0; etc, etc. Also tried adding a colored border around the image, and noticed the the black border was still there within the colored border. Doesn't seem to want to go away.

Work-around's or advice much appreciated.

.share-link {
display: block;
width: 41px;
height: 32px;
text-decoration: none;
background: url("link-icon.png");
}

.share-link:hover {
background-position: -41px 0;
}


<a title="Share this Link" href="#"><img class="share-link"></a>
like image 944
Z with a Z Avatar asked Feb 07 '12 08:02

Z with a Z


People also ask

How do I remove the border around an image in CSS?

Adding border="0" to your img tag prevents that picture from having a border around the image.

How do you remove a border from a picture?

Remove a border from a picture Select the picture whose border you want to remove. On the Page Layout tab, in the Page Background group, select Page Borders. Click the Borders tab. Under Setting, select None.


2 Answers

It's because you are using an img tag with no src attribute. Chrome is essentially indicating the size of the container with nothing in it.

If you don't want to place an image between the anchor tags, then don't use an image tag. It's not necessary to place anything between the tags.

Demo here.

like image 168
Scott Avatar answered Oct 21 '22 02:10

Scott


you can use a base64 very small transparent image

<img class="share-link"  src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"/> 
like image 37
Francesco Avatar answered Oct 21 '22 04:10

Francesco