Why don’t my SVG images scale using the CSS “width” property?

前端 未结 6 897
感情败类
感情败类 2020-12-08 13:10

I\'m building a portfolio website.

HTML Code

6条回答
  •  执笔经年
    2020-12-08 13:48

    SVGs are different than bitmap images such as PNG etc. If an SVG has a viewBox - as yours appear to - then it will be scaled to fit it's defined viewport. It won't directly scale like a PNG would.

    So increasing the width of the img won't make the icons any taller if the height is restricted. You'll just end up with the img horizontally centred in a wider box.

    I believe your problem is that your SVGs have a fixed height defined in them. Open up the SVG files and make sure they either:

    1. have no width and height defined, or
    2. have width and height both set to "100%".

    That should solve your problem. If it doesn't, post one of your SVGs into your question so we can see how it is defined.

提交回复
热议问题