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

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

I\'m building a portfolio website.

HTML Code

6条回答
  •  醉梦人生
    2020-12-08 13:36

    1. If the svg file has a height and width already defined width="100" height="100" in the svg file then add this x="0px" y="0px" width="100" height="100" viewBox="0 0 100 100" while keeping the already defined width="100" height="100".
    2. Then you can scale the svg in your css file by using a selector in your case img so you could then do this: img{height: 20px; width: 20px;} and the image will scale.

提交回复
热议问题