SVG循环进程在Mozilla,Opera中不起作用

问题描述:

我正在尝试使用this代码来实现此SVG循环进度条。SVG循环进程在Mozilla,Opera中不起作用

但它不适用于Chrome以外的浏览器。谁能告诉我这有什么问题?

如下面的代码:

HTML

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<svg width="200px" height="200px" viewBox="-5 0 210 200" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> 
    <path d="M200,100 C200,44.771525 155.228475,0 100,0 C44.771525,0 0,44.771525 0,100 C0,155.228475 44.771525,200 100,200 C155.228475,200 200,155.228475 200,100 Z" class="circle base"></path> 
    <path d="M200,100 C200,44.771525 155.228475,0 100,0 C44.771525,0 0,44.771525 0,100 C0,155.228475 44.771525,200 100,200 C155.228475,200 200,155.228475 200,100 Z" class="circle progress" style="-webkit-animation-duration: 5s;"></path> 
</svg> 

CSS

body { 
    margin: 0; 
    height: 100%; 
    } 

svg { 
    display: table; 
    height: 100%; 
    width: 50%; 
    margin-left: 25%; 
    } 

path.circle { 
    display: table-cell; 
    fill: none; 
    stroke: #DEDEDE; 
    stroke-width: 10; 
    stroke-dasharray: 629; 
    vertical-align: middle; 
    -webkit-transform-origin: center center; 
    } 

    path.progress { 
    stroke: #0094CC; 
    -webkit-animation: progress 20s linear; 
    -webkit-transform: rotate(-90deg) scale(1, -1); 
    } 

    path.base { 
    /* -webkit-animation: base 20s linear; */ 
    -webkit-transform: rotate(-90deg); 
    } 

    @-webkit-keyframes progress { 
    from { stroke-dashoffset: 629; } 
    to { stroke-dashoffset: 0; } 
    } 

    @-webkit-keyframes base { 
     from { stroke-dashoffset: 0; } 
     to { stroke-dashoffset: 629; } 
    } 

任何帮助,将不胜感激:)

编辑: 我的问题是如果我为-moz-添加属性,-o-仍然不能在firefox或opera中工作..可能是什么问题..虽然相同的代码在chrome中工作..我可能会添加额外的东西错过了Firefox或Opera ..我用-moz-,-o-取代了值-webkit-仍然不起作用。

+0

它是如何不工作? Opera或Firefox在控制台中抛出什么错误? –

+1

所以,基本上你想知道为什么'-webkit'只能在webkit浏览器上运行? –

+0

我的问题是,如果我添加-moz-,-o-属性仍然不能在Firefox或Opera中工作..什么可能是问题..而相同的代码在铬中工作.. – user3428616

我认为当用css动画时,尝试使其适应所有浏览器:

-webkit-animation: progress 20s linear; 
-moz-animation: progress 20s linear; 
-o-animation:  progress 20s linear; 
animation:  progress 20s linear; 

做所有的CSS动画谁拥有-webkit-后缀同样的事情,并变换过,希望这有助于

+0

我已经尝试添加,但动画在其他浏览器中无法正常工作 – user3428616

+0

我已经在一个项目上工作并具有saame效果,但我没有用css做动画,但使用jquery和它在我的浏览器中工作我建议你使用jquery进行annimate,使用tween max库或默认的jquery动画,并为stroke-dashoffset proprety –

+0

设置动画感谢解决方案的解决方案,但我想知道是否有任何属性丢失或需要做什么才能工作在其他浏览器..它应该工作,如果我给-moz-或-o- ..但仍然这似乎并没有工作.. – user3428616