Search code examples
csscss-shapes

Is a concave border radius possible?


Here is a simple convex example.

http://jsfiddle.net/swY5k/

#test{
    width: 200px;
    height: 200px;
    background: #888888;
    border-radius: 50px;
}

However, I want a concave border radius.

I tried making the border-radius negative but this did not work.

Example of concave/convex:

enter image description here


Solution

  • You can give the impression of a concave border using radial gradients on the background. For example, something like this:

    #test {
        width: 200px;
        height: 200px;
        background: #888888;
        background:
          radial-gradient(circle 20px at -20% 50%,transparent,transparent 100px,#888888 100px),
          radial-gradient(circle 20px at 120% 50%,transparent,transparent 100px,#888888 100px);
        background-size:100px 200px, 100px 200px;
        background-position:0 0,100% 0;
        background-repeat:no-repeat;
    }
    

    Note that most webkit browsers still require prefixes for radial-gradients, and if you want to fully support older browsers you may need to implement the older gradient syntax too.