Search code examples
cssradial-gradients

How do make a shape with 4 beveled edges


I'm trying to make a shape with four negatively curved corners, and I tried the radial gradients. However, only one of the corners is being applied, and I can't figure out why. https://jsfiddle.net/xiej/1Lqysaho/1/

#shape2 {
  width: 120px;
  height: 120px;
  position: absolute;
  top: 400px;
  right: 400px;
  background-image:
    radial-gradient(circle at 0px 0px, #FFF 0px, #FFF 60px, #F00 60px), 
    radial-gradient(circle at 0px 120px, #FFF 0px, #FFF 60px, #F00 60px), 
    radial-gradient(circle at 120px 0px, #FFF 0px, #FFF 60px, #F00 60px), 
    radial-gradient(circle at 120px 120px, #FFF 0px, #FFF 60px, #F00 60px);
}

Solution

  • The last color stop of each radial gradient is covering up the rest of the square, think of them layering over each other. I'm not sure that my fix is the best way to get the shape you're looking for, but I think this will make the shape at least! I shortened the stops to end the radial gradient before it would cover any of the other three corners.

    https://jsfiddle.net/1Lqysaho/2/

    background: #F00;
    background-image: 
       radial-gradient(circle at 0px 0px, #FFF 60px, #f00 1px, transparent 1px),
       radial-gradient(circle at 0px 120px, #FFF 60px,#f00 1px, transparent 1px),
       radial-gradient(circle at 120px 0px, #FFF 60px,#f00 1px, transparent 1px),
       radial-gradient(circle at 120px 120px, #FFF 60px,#f00 1px, transparent 1px);