svg background image position is always centered in internet explorer, despite background-position: left center;

前端 未结 8 1952
醉话见心
醉话见心 2020-12-04 08:14

I\'m using a SVG logo as a background image and I can\'t seem to get it to align correctly to the left in Internet Explorer (edit: and Safari).

The containe

8条回答
  •  时光取名叫无心
    2020-12-04 09:13

    The accepted answer works, but here's another solution.

    Including the dimensions in the SVG so they are identical to the viewbox dimensions also does the trick.

    width="496px" height="146px" viewBox="0 0 496 146" 
    

    If you're like me and you edit/save your SVG's in Illustrator, untick the "responsive" checkbox in Advanced Options in the save dialog. Then the dimensions will be included.

    (Since it's scalable, it's 'responsive' by definition. So this setting seems a bit redundant.)

提交回复
热议问题