Reputation: 603
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>
Upvotes: 20
Views: 18979
Reputation: 411
You can just put the "src" attribute blank that will fade the border
<img class="share-link" src="">
Upvotes: 0
Reputation: 1
My base64 embedded images kept showing a grey line around it no matter what I did. Using <div>
instead of <img>
worked for me.
BEFORE (wrong) I used:
in HTML:
<img class='message-bubble-small'>
in CSS:
img.message-bubble-small {
background-image: url(data:image/png;base64,...);
background-size: 16px 16px;
width: 16px;
height: 16px;
float: left;
}
AFTER I used:
in HTML:
<div id='message-bubble-small'>
in CSS:
#message-bubble-small {
background-image: url(data:image/png;base64,...);
background-size: 16px 16px;
width: 16px;
height: 16px;
float: left;
}
With the last example I have no more grey lines in Chrome.
Upvotes: 0
Reputation: 1148
you can use a base64 very small transparent image
<img class="share-link" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"/>
Upvotes: 9
Reputation: 1
By default any image that is wrapped in a link will have a border around the image (similar to the way text is underlined). Removing the border is simple
a image {border: none} or a image {border: 0}
Since I never want to see the border around image links I usually set the above on every site I develop
Upvotes: -2
Reputation: 591
It's a Chrome bug, ignoring the "border:none;" style.
Let's say you have an image "download-button-102x86.png" which is 102x86 pixels in size. In most browsers, you would reserve that size for its width and height, but Chrome just paints a border there, no matter what you do.
So you trick Chrome into thinking that there is nothing there - size of 0px by 0px, but with exactly the right amount of "padding" to allow for the button. Here is a CSS id block that I am using to accomplish this...
#dlbutn {
display:block;
width:0px;
height:0px;
outline:none;
padding:43px 51px 43px 51px;
margin:0 auto 5px auto;
background-image:url(/images/download-button-102x86.png);
background-repeat:no-repeat;
}
Viola! Works everywhere and gets rid of the outline/border in Chrome.
Upvotes: 3
Reputation: 21890
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.
Upvotes: 43
Reputation: 751
If your asking to get rid of the border which activates onfocus then:
*:focus {outline: none;}
or
.nohighlight:focus { outline:none; }
This should get rid of the border.
Upvotes: 1