height: auto on SVG not working

后端 未结 2 453
感情败类
感情败类 2020-12-31 02:35

I am trying to use an SVG sprite sheet using the \"symbol\" method detailed here.

http://css-tricks.com/svg-sprites-use-better-icon-fonts/

My HTML is very si

2条回答
  •  無奈伤痛
    2020-12-31 02:54

    DEMO

    You need to define a viewBox on each element that you link to. because there can be different elements in one SVG document.

    So remove the viewBox from the element you link to. Add a viewBox to the place you're linking from.

    I suggest you add the viewBox to a svg element:

    
        
    
    

    Now you can scale it:

    If you define the css width:

    .test {
        width: 50px;
    }
    

    It will display as long as it fits on height or width.

    So if you want a responsive design you can simply scale it by % length
    .test { width:30%; }

    SCALE SVG A really good article about scaling svg from CSS-tricks :)

提交回复
热议问题