Draw double curved item with beveled edges

前端 未结 4 1579
半阙折子戏
半阙折子戏 2021-01-14 01:16

I\'m creating a website, with a header / menu on top. In the middle, there is a logo. To accentuate this, I\'ve absolute positioned an ellips below the logo: So underneath,

4条回答
  •  北海茫月
    2021-01-14 01:34

    Almost there ... it could get you in the way.

    I used ::before and ::after on the header to add two curve.

    Play a little with the values of the radius to get what you want.

    The ellips has a fixed width, so this is as responsive as possible. When resizing the screen, the corners won't break but the ellip's size won't change.

    html,
    body {
      margin: 0;
      padding: 0;
    }
    
    *,
    *::before,
    *::after {
      box-sizing: border-box;
    }
    
    body {
      background: linear-gradient(to right, #d2e1f1, #86acd0);
    }
    
    header {
      height: 100px;
      background: white;
      position: relative;
    }
    header::before, header::after {
      content: "";
      display: block;
      width: calc(50% - 80px);
      position: absolute;
      top: 95px;
      height: 80px;
      border: 6px solid #dadbe0;
      border-right-color: transparent;
      border-left-color: transparent;
      border-bottom: 0;
      z-index: 3;
    }
    header::before {
      left: 0px;
      border-radius: 0px 140px 0px 0px/0px 60px 0px 0px;
    }
    header::after {
      right: 0px;
      border-radius: 140px 0px 0px 0px/60px 0px 0px 0px;
    }
    
    .ellips {
      background: white;
      height: 120px;
      width: 300px;
      position: absolute;
      bottom: -40px;
      z-index: -1;
      border-radius: 0px 0px 90% 90%/0px 0px 90px 90px;
      left: 50%;
      transform: translate(-50%);
      border: 6px solid #dadbe0;
    }
    
    .masks {
      background: white;
      height: 9px;
      width: 330px;
      position: absolute;
      bottom: 0;
      left: 50%;
      transform: translateX(-50%);
      z-index: 2;
      border-radius: 0px 0px 90% 90%/0px 0px 90px 90px;
      bottom: -8px;
    }

提交回复
热议问题