How to make SVG “fill” act in a similar way to CSS “background-size: cover”

前端 未结 2 1573
旧巷少年郎
旧巷少年郎 2021-01-17 11:56

I\'m am trying to create an SVG which masks an image with a particular path however, when I try to fill the area using a pattern, the image does not cover the entire area.

2条回答
  •  萌比男神i
    2021-01-17 12:20

    If background-position is needed as well as background-size: cover;

    preserveAspectRatio="xMidYMid slice" // Will center the image

    This link has all options available for the preserveAspectRatio attribute. And can help with centering the image within the pattern

    All Options

提交回复
热议问题