javascript - css3 关键帧过渡在 chrome 中不起作用?

标签 javascript css google-chrome

我有下面的也可用here .

我希望背景像在 ff 和 ie 中那样移动,但由于某种原因它在 chrome 中不起作用? 是我做错了什么还是 webkit 不支持我包含的东西?

    <div id="box"></div>

    @keyframes movingbg {
        from {
            background-position:0 0;
        }
        to {
            background-position:center center;
        }
    }

    #box {
        -webkit-animation-name: movingbg;
        -o-animation-name: movingbg;
        -ms-animation-name: movingbg;
        -moz-animation-name: movingbg;
        animation-name: movingbg;
        -webkit-animation-iteration-count: 1;
        -o-animation-iteration-count: 1;
        -ms-animation-iteration-count: 1;
        -moz-animation-iteration-count: 1;
        animation-iteration-count: 1;
        -webkit-animation-duration: 5s;
        -o-animation-duration: 5s;
        -ms-animation-duration: 5s;
        -moz-animation-duration: 5s;
        animation-duration: 5s;
        -webkit-animation-fill-mode: forwards;
        -o-animation-fill-mode: forwards;
        -ms-animation-fill-mode: forwards;
        -moz-animation-fill-mode: forwards;
        animation-fill-mode: forwards;
        background: url("http://lorempixel.com/600/400/sports/") no-repeat scroll center 0 rgba(0, 0, 0, 0);
        width: 300px;
        height: 200px;
    }

最佳答案

DEMO

您在 ID 中有 vendor 前缀,但不幸的是您在关键帧调用中遗漏了它们...

只需将其添加到您的 CSS 代码中:

@-webkit-keyframes movingbg {
    from {
        background-position:0 0;
    }
    to {
        background-position:center center;
    }
}

您可以将动画设置为在 -webkit 浏览器中工作

关于javascript - css3 关键帧过渡在 chrome 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21542600/

相关文章:

javascript - 使用 Material UI 时 react 冲突

html - CSS - 悬停时仅更改 DIV 内的 DIV 字体颜色

javascript - "Uncaught TypeError: Illegal invocation"与 HTML5 数据库

javascript 动画不适用于 chrome 和 IE

javascript - 使用 AngularJs 分页中的搜索框过滤器

javascript - 显示表单字段的 Bootstrap-slider

javascript - Typeahead:如何将数据列表分为 3 个不同的部分? [如多数据集]

html - 在不中断表单流的情况下在输入字段前添加一个图标

jquery - Bootstrap 表单布局(移动端和桌面端的元素顺序不同)

jquery - 为什么我的 bx-slider 不显示 chrome 中的图像?