Draw double curved item with beveled edges

前端 未结 4 1611
半阙折子戏
半阙折子戏 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:39

    I created 2 SVG examples so you can choose where to apply the background

    Codepen demo


    The outer container of each SVG element keeps a specific aspect ratio so the whole element can be responsive (but, of course, you can also specify a fixed width or height).

    The basic idea is to create a path that overflows the size of the SVG element, so you can define a closed shape on the top area or on the bottom area, in order to fill it with a colour (if you enlarged the viewbox e.g. to -10 -10 610 130 you could see how the path is actually defined).

    The applied background is a gradient but you can also specify a single color-stop (white, in your specific scenario). The background on the body element shows the transparent parts of the SVG.

    Fine tuning and adjustment of curves, viewbox, colours is left to the reader.

    For any change to the shape you can read the path documentation on MDN

    Markup

    CSS

    .doublecurve {
      width: 100%;
      height: 0;
      margin: 20px 0;
      border: 1px dashed #bc9;
      padding-bottom: 20%;
      position: relative; }
    
    .doublecurve svg { 
      position: absolute;
      width: 100%; height: 100%;}
    
    .doublecurve path.concave { 
      stroke: #d0d0d0; 
      stroke-width: 4px;}
    

    Final Result

提交回复
热议问题