img src SVG changing the styles with CSS

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

html

\"Logo\"

css

.logo-img path {
           


        
22条回答
  •  猫巷女王i
    2020-11-22 02:00

    Since SVG is basically code, you need just contents. I used PHP to obtain content, but you can use whatever you want.

    
    

    Then, I've printed content "as is" inside a div container

    To finnaly set rule to container's SVG childs on CSS

    .fill-class > svg { 
        fill: orange;
    }
    

    I got this results with a material icon SVG:

    Mozilla Firefox 59.0.2 (64-bit) Linux

    Google Chrome66.0.3359.181 (Build oficial) (64 bits) Linux

    Opera 53.0.2907.37 Linux

提交回复
热议问题