filter:blur for mozilla firefox <svg> not wo

2019-03-03 20:14发布

问题:

I am developing a page that will animate the image, fade in with blur style. It works in google chrome but in mozilla firefox didn't.

I try this approach for the mozilla firefox . http://css-plus.com/2010/05/how-to-add-a-gaussian-blur-effect-to-elements-within-firefox/ but the images were not visible.

this is my code :

js:

<script type="text/javascript">
$(document).ready(function() {
    $("img").css({
        "filter": "blur(4px)", 
        "-webkit-filter": "blur(4px)", 
        "-moz-filter": "blur(4px)",
        "-o-filter": "blur(4px)",
        "-ms-filter": "blur(4px)",
        "filter":"url('#blur1')"
    });
    window.setTimeout(function() {
        $("img").css({
            "filter": "blur(3px)", 
            "-webkit-filter": "blur(3px)", 
            "-moz-filter": "blur(3px)",
            "-o-filter": "blur(3px)",
            "-ms-filter": "blur(3px)",
            "filter":"url('#blur1')"
        });
    }, 3000);
    window.setTimeout(function() {
        $("img").css({
            "filter": "blur(2px)", 
            "-webkit-filter": "blur(2px)", 
            "-moz-filter": "blur(2px)",
            "-o-filter": "blur(2px)",
            "-ms-filter": "blur(2px)",
            "filter":"url('#blur1')"
        });
    }, 3100);
    window.setTimeout(function() {
        $("img").css({
            "filter": "blur(1.5px)", 
            "-webkit-filter": "blur(1.5px)", 
            "-moz-filter": "blur(1.5px)",
            "-o-filter": "blur(1.5px)",
            "-ms-filter": "blur(1.5px)",
            "filter":"url('#blur1')"
        });
    }, 3200);
    window.setTimeout(function() {
        $("img").css({
            "filter": "blur(1px)", 
            "-webkit-filter": "blur(1px)", 
            "-moz-filter": "blur(1px)",
            "-o-filter": "blur(1px)",
            "-ms-filter": "blur(1px)",
            "filter":"url('#blur1')"

        });
    }, 3300);
    window.setTimeout(function() {
        $("img").css({
            "filter": "", 
            "-webkit-filter": "", 
            "-moz-filter": "",
            "-o-filter": "",
            "-ms-filter": "",
            "filter":"url('#blur1')"
        });
    }, 3400);
    $("#promoIMG").fadeIn(5000);
});
</script>

html:

<div id="promoIMG">
    <a href="main.php"><img src="images/akb1.png" alt="" onMouseOver="this.src='images/akb2a.png'" onMouseOut="this.src='images/akb1.png'"/></a><br/>
    <img src="images/akb2.png" alt="AKB" />
</div>
</div>
<svg>
    <filter id="blur1">
        <svg:feGaussianBlur stdDeviation="1"/>
     </filter>
</svg>

where did I do wrong? and how can I make it correct so that the page animation of mozilla firefox will be same in chrome.

thanks in advance

回答1:

I got it, I add this

<svg height="0" xmlns="http://www.w3.org/2000/svg">
<filter id="blur1">
        <svg:feGaussianBlur stdDeviation="1"/>
     </filter>
</svg>


回答2:

Had the same problem; image not showing (similar to the @kidwon's jsbin). solved it by having the svg snippet located in an external file and loading it via

filter: url("/blur.svg#blur");

in the css. QUOTED, did not worked without.