且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

添加边框半径时,边框和图像之间的间隙

更新时间:2022-10-19 14:05:46

只需添加背景颜色,与您的边框颜色相同,并且已修复。



请参阅 jsFiddle


I have an image with a border radius of 50% and a 3px border around it. My problem is when the border radius is given, there is a 1px gap between the image and the border.

Issue is demonstrated in the below image.

And the css I'm using,

img {
    border: 3px solid #4CB7AC;
    height: 46px;
    width: 46px;
    border-radius:50%;
}

Note that

  • The image size is 46px X 46px. Not resized.
  • And I HAVE to use <img> to get the image. Setting it as a background image is ruled out.
  • Solution must be compatible with all browsers. Even IE8.

Is there a way to remove that gap?

EDIT JS Fiddle link

Just Add Background color same as your Border color and it's fixed.

See jsFiddle