簡體   English   中英

CSS @keyframes 在 Chrome 中不起作用

[英]CSS @keyframes not working in Chrome

我正在試驗 CSS3 @keyframes 動畫,但我沒有設法讓它在 Chrome 中工作(目前我有 Chrome 38)

代碼非常簡單:

HTML

<div id="block">moving text</div>


CSS

@keyframes mymove
{
    0%   {top:0px;}
    25%  {top:200px;}
    50%  {top:100px;}
    75%  {top:200px;}
    100% {top:0px;}
}

#block {
    position:absolute;
    animation: mymove 2s infinite;
}

這是一個具有相同代碼的小提琴

對我來說,文本在 Chrome 38 中沒有移動,但在 Firefox 30 和 IE 11 上運行良好。

我嘗試使用@-webkit-keyframes但文本在 Chrome 中也沒有移動。

您需要在樣式屬性和關鍵幀函數上使用供應商前綴

演示小提琴

@-webkit-keyframes mymove /* <--- here */
{
    0%   {top:0px;}
    25%  {top:200px;}
    50%  {top:100px;}
    75%  {top:200px;}
    100% {top:0px;}
}

#block {
    position:absolute;
    -webkit-animation: mymove 2s infinite;/* <--- and here */
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM