0

我只是想知道是否有办法在纯基于 CSS3 的设计中使用一点 HTML5 或 jquery 来制作背景动画?

我可以看到有些人这样做

http://addtwitter-followers.com/

在 CSS3 中有没有简单的方法来做到这一点?

4

1 回答 1

2

Fiddle DEMO

CSS

@keyframes animatedBackground {
    from {
        background-position: 0 0;
    }
    to {
        background-position: 100% 0;
    }
}
@-webkit-keyframes animatedBackground {
    from {
        background-position: 0 0;
    }
    to {
        background-position: 100% 0;
    }
}
@-ms-keyframes animatedBackground {
    from {
        background-position: 0 0;
    }
    to {
        background-position: 100% 0;
    }
}
@-moz-keyframes animatedBackground {
    from {
        background-position: 0 0;
    }
    to {
        background-position: 100% 0;
    }
}
#wrap {
    height:100%;
    width:100%;
    background: url(http://addtwitter-followers.com/wp-content/themes/twentyten/images/bck.jpg) top no-repeat #94E3F4;
    background-position: 0px 0px;
    background-repeat: repeat-x;
    animation: animatedBackground 150s linear infinite;
    -ms-animation: animatedBackground 150s linear infinite;
    -moz-animation: animatedBackground 150s linear infinite;
    -webkit-animation: animatedBackground 150s linear infinite;
}

HTML

<div id="wrap">...</div>


References

@keyframes

animation:

animations

于 2013-11-15T01:40:57.300 回答