SVG filter only working when added in style attribute (Firefox)

前端 未结 7 539
醉酒成梦
醉酒成梦 2021-01-01 17:28

I added a blur effect svg to my HTML(text/html):


    ...
    
        ...
        

        
7条回答
  •  独厮守ぢ
    2021-01-01 18:16

    In my case Firefox didn't find an SVG filter because of the CSS rule:

    #svg-filters {
        display: none;
    }
    

    where svg-filters is the id of the tag containing all filters definitions. Replaced those lines with

    #svg-filters {
        position: absolute;
        height: 0;
        width: 0;
    }
    

    and filters work fine in FF.

    Referencing filters relative to the HTML document from CSS works fine in major browsers, as pointed out by Josh Powell in his answer.

提交回复
热议问题