Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rounded corners in Firefox: space between border and background

Tags:

html

css

firefox

I have a div that I am applying rounded corners to.

Here is my demo fiddle.

<div>&nbsp;</div>
div {
    margin: 20px;
    width: 250px;
    height: 250px;
    -moz-border-radius: 15px;
    -webkit-border-radius: 15px;
    -khtml-border-radius: 15px;
    border-radius: 15px;
    background-color: #4c66a1;
    border: 2px solid #4c66a1;
}

I also have a border and background color applied to this div. The issue arises in Firefox. There is a small amount of whitespace between the border and the background-color of the div (see images below). It is very minimal, but people have noticed it nonetheless. It looks like a lighting effect on the corner.

Is this a known issue with rounded corners in Firefox? IE, Chrome, and Opera are fine.

FYI/ For the purposes of illustrating the issue I have made the border and background-color the same even though it's redundant. It makes the whitespace stand out more.

 Firefox      Chrome/IE/Opera

enter image description here         enter image description here

like image 315
Matt K Avatar asked Mar 06 '12 17:03

Matt K


People also ask

How do you put a space between borders and divs?

Padding could be added to the container (outer) element to push the element inside away from it's border. Margin could be used on the inner element to push itself away from the container.

Why border-radius is not working?

If there are contents within the div that has the curved corners, you have to set overflow: hidden because otherwise the child div's overflow can give the impression that the border-radius isn't working.

What does border-radius do?

The border-radius CSS property rounds the corners of an element's outer border edge. You can set a single radius to make circular corners, or two radii to make elliptical corners.


2 Answers

Interestingly, if we change it to dotted, the white goes away:

div {
    margin: 20px;
    width: 250px;
    height: 250px;
    -moz-border-radius: 30px;
    -webkit-border-radius: 30px;
    -khtml-border-radius: 30px;
    border-radius: 30px;
    background-color: #4c66a1;
    border: 2px dotted #4c66a1;
}

http://jsfiddle.net/5yAkZ/23/

EDIT had invalid css previously

like image 129
Chris Young Avatar answered Oct 06 '22 00:10

Chris Young


See https://bugzilla.mozilla.org/show_bug.cgi?id=704399 which is fixed in Firefox 11 and newer.

like image 43
Boris Zbarsky Avatar answered Oct 06 '22 01:10

Boris Zbarsky