img src SVG changing the styles with CSS

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

html

\"Logo\"

css

.logo-img path {
           


        
22条回答
  •  死守一世寂寞
    2020-11-22 02:10

    The answer from @Praveen is solid.

    I couldn't get it to respond in my work, so I made a jquery hover function for it.

    CSS

    .svg path {
       transition:0.3s all !important;
    }
    

    JS / JQuery

    // code from above wrapped into a function
    replaceSVG();
    
    // hover function
    // hover over an element, and find the SVG that you want to change
    $('.element').hover(function() {
        var el = $(this);
        var svg = el.find('svg path');
        svg.attr('fill', '#CCC');
    }, function() {
        var el = $(this);
        var svg = el.find('svg path');
        svg.attr('fill', '#3A3A3A');
    });
    

提交回复
热议问题