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

前端 未结 8 1930
醉话见心
醉话见心 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.)

    0 讨论(0)
  • 2020-12-04 09:18

    It turns out the following line can turn your svg into a non-centered element:

    display: inline-block;
    

    Still not the most ideal solution but it works.

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