Semi-oval with CSS

后端 未结 3 403
清酒与你
清酒与你 2020-12-18 21:50

I\'m trying to create a mix between an oval and a semi-circle.

Semi-circles can be created as such in CSS:

.halfCircle{
     height:45px;
     width         


        
3条回答
  •  借酒劲吻你
    2020-12-18 22:15

    I've updated your demo with one possible solution:

    div {
      background-color: #80C5A0;
      width: 400px;
      height: 100px;
      border-radius: 50% / 100%;
      border-bottom-left-radius: 0;
      border-bottom-right-radius: 0;
    }

    By using percentage based units for the border-radius it should always keep a smooth semi-ellipse regardless of your width and height values.

    With a few minor changes, here's how you'd render the semi-ellipse split in half vertically:

    div {
      background-color: #80C5A0;
      width: 400px;
      height: 100px;
      border-radius: 100% / 50%;
      border-top-left-radius: 0;
      border-bottom-left-radius: 0;
    }

提交回复
热议问题