2017-02-07 138 views
0

我一直在努力修復我今晚用於Firefox的CSS類型寫作動畫 - 迄今爲止沒有成功。 Chrome代碼正常工作。我錯過了什麼人?CSS鍵入動畫不適用於Firefox

.css-typing 
{ 
    width: 680px; 
    white-space: nowrap; 
    overflow: hidden; 
    -webkit-animation: type 3s steps(50, end); 
    animation: type 3s steps(55, end); 
    -o-animation: type 5s steps(50, end); 
    -moz-animation: type 3s steps(55, end); 
    } 


@keyframes type 
    { 
     from { width: 0; } 
    } 

@-moz-keyframes type 
    { 
     from { width: 0; } 
    } 

@-webkit-keyframes type 
    { 
     from { width: 0; } 
    } 

這也在這段代碼中定義的股利如下:

<div class='css-typing'>This text will pop up using an typewriting effect</div> 

有誰發現我的錯誤?

+0

除了'div'沒有'.css-typing'嗎? – TricksfortheWeb

+0

錯別字......就像上面提到的那樣,它可以在Chrome上運行,所以 –

回答

1

您需要設置@keyframes塊的to一部分,你還需要設置元素的寬度:https://jsfiddle.net/yak613/vtdyuju4/

.css-typing { 
    width: 360px; 
    white-space: nowrap; 
    overflow: hidden; 
    -webkit-animation: type 3s steps(50, end); 
    animation: type 3s steps(55, end); 
    -o-animation: type 5s steps(50, end); 
    -moz-animation: type 3s steps(55, end); 
} 


@keyframes type 
    { 
     from { width: 0; } 
     to { width: 360px; } 
    } 

@-moz-keyframes type 
    { 
     from { width: 0; } 
     to { width: 360px; } 
    } 

@-webkit-keyframes type 
    { 
     from { width: 0; } 
     to { width: 360px; } 
    } 
+0

嗯,這仍然不起作用= /我的firefox版本是最新的2日期。 –

+0

我在Ubuntu 16.01上的Firefox 51中測試過它,它工作正常。你確定沒有你忽略的東西嗎? – TricksfortheWeb

+0

我正在查看。小提琴代碼適合我,但我的代碼似乎沒有做任何事情在Firefox上。 也許這是一個wordpress的東西,我不確定。試圖解決這個問題。 謝謝你的幫助壽! –

0

W3C建議最佳瀏覽器的支持,一個「從」和「到「都是在@keyframes內定義的。嘗試將您的代碼更改爲:

.css-typing 
{ 
    width: 680px; 
    white-space: nowrap; 
    overflow: hidden; 
    -webkit-animation: type 3s steps(50, end); 
    animation: type 3s steps(55, end); 
    -o-animation: type 5s steps(50, end); 
    -moz-animation: type 3s steps(55, end); 
    } 


@keyframes type 
    { 
     from { width: 0; }, 
     to {width:680px} 
    } 

@-moz-keyframes type 
    { 
     from { width: 0; }, 
     to {width:680px} 
    } 

@-webkit-keyframes type 
    { 
     from { width: 0; } 
     to {width:680px} 
    } 
相關問題