Fill a div with a wavy border SVG path

前端 未结 2 1095
你的背包
你的背包 2021-01-18 23:14

I want to fill the

with the color and add shadow to the border but my code is doing this. I actually need it in the way shown in the image.

相关标签:
2条回答
  • 2021-01-18 23:25

    In your code, you where creating several path elements where each element had one curveTo subpath. Instead, you need one path element with several curveTo subpaths. In your scenario, the simpler quadratic Bezier curve will work well. After the curveTo subpaths, you will need some lineTo subpaths to define the area under the curves. For example...

    <svg height="150" width="880">
      <path d="M 0 100 q 40 -40 80 0 q 40 40 80 0 q 40 -40 80 0 q 40 40 80 0 q 40 -40 80 0 q 40 40 80 0 q 40 -40 80 0 q 40 40 80 0  q 40 -40 80 0 q 40 40 80 0 q 40 -40 80 0 l 0 50 l -880 0 z" stroke="rgb(255, 195, 56)" stroke-width="5" fill="rgb(255, 195, 56)"/>
    </svg>

    0 讨论(0)
  • 2021-01-18 23:40

    For such a shape, you can use an svg pattern and fill a rectangle width the pattern as shown in the following example :

    html,body{margin:0;padding:0;}
    div{
      background: url('http://i.imgur.com/qi5FGET.jpg');
      background-size:cover;
      overflow:hidden;
    }
    svg{display:block;}
    <div>
      <h1>title</h1>
      <p>whatever content<br/>with several lines</p>
      <svg viewbox="0 0 60 10">
        <pattern x="-7.5" id="waves" patternUnits="userSpaceOnUse" width="10" height="10">
          <path d="M0 10 V5 Q2.5 2.5 5 5 T10 5 V10" fill="#FFC338" />
        </pattern>
        <rect x="0" y="0" width="60" height="10" fill="url(#waves)"/>
      </svg>
    </div>

    0 讨论(0)
提交回复
热议问题