Remove border around circular image


John Du

I have a circular image (.png file) with transparency in the middle. I need to make the background inside the image a solid color. For this I make the background solid and put in border-radius:50%, but this produces ugly little white lines. Is there anyway to get rid of it, or do I have to manually colorize the image in the image editor?

div {
  width: 500px;
  height: 500px;
  background: black;
}
div img {
  margin: 100px;
  max-width: 50%;
  background: white;
  border-radius: 50%;
}
<div>
  <img src="http://i.imgur.com/sDU7Lhz.png">
</div>

Fiddle here : https://jsfiddle.net/h3nwkoe1/

Harry

The problem is not the image. The image is transparent and has no background at all. The problem is caused by adding background: whiteand border-radius: 50%to the image element. This is due to antialiased pixels in browsers and is the same problem described in this thread .

The solution is to use some method to partially fill the background onto the element, but not completely (ie, until enough to cover the black circle that is already on the image). Since imgmarkup cannot contain pseudo-elements (at least it doesn't work cross-browser), your best bet is to use a radial-gradientas a background, as shown in the code snippet below.

Note: The thick green border is for demonstration only and can be removed without any side effects.

div {
  width: 500px;
  height: 500px;
  background: black;
}
div img {
  margin: 100px;
  max-width: 50%;
  background: radial-gradient(circle at center, white 60%, transparent 61%);
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid green;
}
<div>
  <img src="http://i.imgur.com/sDU7Lhz.png">
</div>

Related


Remove border around circular image

John Du I have a circular image (.png file) with transparency in the middle. I need to make the background inside the image a solid color. For this I make the background solid and put in border-radius:50%, but this produces ugly little white lines. Is there an

Remove border around circular image

John Du I have a circular image (.png file) with transparency in the middle. I need to make the background inside the image a solid color. For this I make the background solid and put in border-radius:50%, but this produces ugly little white lines. Is there an

Remove border around circular image

John Du I have a circular image (.png file) with transparency in the middle. I need to make the background inside the image a solid color. For this I make the background solid and put in border-radius:50%, but this produces ugly little white lines. Is there an

Remove border around circular image

John Du I have a circular image (.png file) with transparency in the middle. I need to make the background inside the image a solid color. For this I make the background solid and put in border-radius:50%, but this produces ugly little white lines. Is there an

Remove border around circular image

John Du I have a circular image (.png file) with transparency in the middle. I need to make the background inside the image a solid color. For this I make the background solid and put in border-radius:50%, but this produces ugly little white lines. Is there an

Remove border around circular image

John Du I have a circular image (.png file) with transparency in the middle. I need to make the background inside the image a solid color. For this I make the background solid and put in border-radius:50%, but this produces ugly little white lines. Is there an

How to put a multicolor border around a circular image?

Sykes I need to put a colored border around a circular image. Border example I've tried various guides online but can't seem to get the hang of it. I tried using a linear gradient, but I ended up with 4 points at the corners, as if the image were square with n

How to put a multicolor border around a circular image?

Sykes I need to put a colored border around a circular image. Border example I've tried various guides online but can't seem to get the hang of it. I tried using a linear gradient, but I ended up with 4 points at the corners, as if the image were square with n

Remove border around image in Pygame

username I have some surfaces in Pygame with transparent backgrounds. They are all the same size. But there is a different sized circle on each pixel, so the circle doesn't exactly fit the image. Here are some sample images (I took screenshots in Photoshop so

How to remove the image around the border

Edwin So I have a question. I used sprites for the first time and now borders appear around them, I tried setting border: none, but it didn't work. demo <div class="service"> <img href="image/icons.png" style="background-image:url('image/icons.png'); backgroun

Remove border around image in Pygame

username I have some surfaces in Pygame with transparent backgrounds. They are all the same size. But there is a different sized circle on each pixel, so the circle doesn't exactly fit the image. Here are some sample images (I took screenshots in Photoshop so

How to remove the image around the border

Edwin So I have a question. I used sprites for the first time and now borders appear around them, I tried setting border: none, but it didn't work. demo <div class="service"> <img href="image/icons.png" style="background-image:url('image/icons.png'); backgroun

Strange border around arrow image, how to remove it?

principal fund I'm using slick sliders for our team carousel. There is a weird border around the arrow image to click on the next slide. I've tried removing all CSS that affects arrow images, google searches, stack overflow, etc. How can I remove this border?

How can I remove the border around the image?

username How can I remove the border around the square? Exterior: my HTML: <input id="black" type="image" src="html5-canvas-drawing-app/images/color-swatch-brown.png" onClick="changeColorBlack()"> my css: #black{ border:none; outline:none; background:none; pa

Remove default border around image - Chrome browser

Zach I can't believe it's the first time I've encountered this problem. I've searched many other similar questions on SO regarding the same issue, but none of them worked for me. I have an img tag with a class attribute under the anchor tag. So my html looks l

Strange border around arrow image, how to remove it?

principal fund I'm using slick sliders for our team carousel. There is a weird border around the arrow image to click on the next slide. I've tried removing all CSS that affects arrow images, google searches, stack overflow, etc. How can I remove this border?

Strange border around arrow image, how to remove it?

principal fund I'm using slick sliders for our team carousel. There is a weird border around the arrow image to click on the next slide. I've tried removing all CSS that affects arrow images, google searches, stack overflow, etc. How can I remove this border?

Darker border around circular CALayer

Oliver Cooper I'm creating a custom view to display a color, it's for a color picker in an image, so the color may change quickly. To prevent the color from flickering as the cursor moves, I made it to animate the color change in 0.2 seconds. I am using CALaye

Partial circular border around element

original I am trying to achieve this without an image (yellow): The most detailed border generator I've found is this generator available in MDN . But it doesn't work. Is there any other way? Harry Yes, it can be achieved by a combination of the inset in the l

Make a circular border around the text

tracer Now, I want to put a plus sign around it. http://jsfiddle.net/dtracers/cvtztcy1/1/ <h1>TEXY TXT <span>+</span></h1> <style> span { border-radius: 50%; border-style:solid; border-width: 1px 3px 1px 1px; padding:0px; padding-bottom:0.

Darker border around circular CALayer

Oliver Cooper I'm creating a custom view to display a color, it's for a color picker in an image, so the color may change quickly. To prevent the color from flickering as the cursor moves, I made it to animate the color change in 0.2 seconds. I am using CALaye

Partial circular border around element

original I am trying to achieve this without an image (yellow): The most detailed border generator I've found is this generator available in MDN . But it doesn't work. Is there any other way? Harry Yes, it can be achieved by a combination of the inset in the l

Partial circular border around element

Prims I am trying to achieve this without an image (yellow): The most detailed border-generator I've found is this generator available in MDN . However, it doesn't work. Is there any other way? Harry Yes, this can be achieved box-shadowwith a combination of th

Partial circular border around element

Prims I am trying to achieve this without an image (yellow): The most detailed border-generator I've found is this generator available in MDN . However, it doesn't work. Is there any other way? Harry Yes, this can be achieved box-shadowwith a combination of th

remove border around dash

Formenti Matteo I want to remove the huge dotted border around the dash in Ubuntu 16.04. Google hasn't been my friend lately, I just can't find any results... Compizconfig doesn't contain any options for this. Can someone help me? More than There is no setting

remove border around dash

Formenti Matteo I want to remove the huge dotted border around the dash in Ubuntu 16.04. Google hasn't been my friend lately, I just can't find any results... Compizconfig doesn't contain any options for this. Can someone help me? More than There is no setting