img src SVG changing the styles with CSS

后端 未结 22 2515
予麋鹿
予麋鹿 2020-11-22 01:16

html

\"Logo\"

css

.logo-img path {
           


        
22条回答
  •  感动是毒
    2020-11-22 01:58

    Know this is an old question but recently we came across the same issue, and we solved it from the server side. This is a php specific answer but I am positive that other envs have something similar. instead of using the img tag you render the svg as svg from the get-go.

    public static function print_svg($file){
        $iconfile = new \DOMDocument();
        $iconfile->load($file);
        $tag = $iconfile->saveHTML($iconfile->getElementsByTagName('svg')[0]);
        return $tag;
    }
    

    now when you render the file you will get complete inline svg

提交回复
热议问题