Search code examples
bordercss

box-shadow and border rendering bug


Css causing the "bug":

div {
    width: 100px;
    height: 100px;
    background-color: transparent;
    box-shadow: 0 0 15px 20px #000 inset;
    border: 100px solid #000 ;
    border-radius: 150px;
}

It looks like there is some kind of 1px transparent border between the inset box-shadow and the surrounding border.

Have a look at this live example, i could reproduce that rendering weirdness with the last releases of Chrome, Firefox and IE. (thus not rendering engine-dependent)

And it doesn't happen with a lower border-radius (in other words, it doesn't happen when the shape is not a circle)

EDIT:

I didn't find a way to make this thing go away, but using a low opacity makes it almost invisible. I'll be using that technique (and leaving the question open) until a real solution comes up.


Solution

  • Definitely looks like a bug in box-shadow (when using the spread arg). As a work-around just use an overlay div. Here's the code:

    html:

    <div></div>
    <div class="overlay"></div>
    

    css:

    div {
        margin:10px;
        width: 100px;
        height: 100px;
        background-color: transparent;
        box-shadow: 0 0 15px 20px #000 inset;
        border: 100px solid #000 ;
        border-radius: 150px;
    }
    div.overlay {
        margin-top:-310px;
    }
    

    Here's the fiddle: http://jsfiddle.net/eX3cy/1/

    Edit:

    Here's a fiddle with the blur and spread adjusted as well (to show that identical results, minus the unwanted parts, can be achieved): http://jsfiddle.net/wgpzL/