2

我创建了一个小提琴,但我认为它的显示不正确。http://jsfiddle.net/kVNQb/但无论如何查看代码可能很有用。

我正在使用 CSS 动画从该站点http://cssdeck.com/labs/css3-snow创建雪

我想做的是设置一个背景图像,然后让雪在其顶部进行动画处理。目前我失去了动画雪或背景图像。

我需要创建一个 id 并将我想要的图像设置为背景吗?

HTML 代码

<body>

    <div class="row">
        <div class="large-12 columns">
            <div id="container">
        </div>
            </div>

    </div>

</body>

CSS 代码

/*Custom CSS styles being used on top of the standard Foundation 4 style sheet*/
 fixed.body {
 background-image: url(http://s17.postimg.org/9htu61zjj/background.jpg);
}


* {
    margin: 0;
    padding: 0;
}

a {
    color: white;
    font-style: italic;
}

/*Keyframes*/

@keyframes snow { 
    0% { background-position: 0px 0px, 0px 0px, 0px 0px }

    100% { background-position: 500px 1000px, 400px 400px, 300px 300px }
}

@-moz-keyframes snow { 
    0% { background-position: 0px 0px, 0px 0px, 0px 0px }

    100% { background-position: 500px 1000px, 400px 400px, 300px 300px }
}

@-webkit-keyframes snow { 
    0% { background-position: 0px 0px, 0px 0px, 0px 0px }

    50% { background-color: #b4cfe0 }

    100% {
        background-position: 500px 1000px, 400px 400px, 300px 300px;
        background-color: #6b92b9;
    }
}

@-ms-keyframes snow { 
    0% { background-position: 0px 0px, 0px 0px, 0px 0px }

    100% { background-position: 500px 1000px, 400px 400px, 300px 300px }
}

/*body {
    background-color: #6b92b9;
    background-image: url('http://img138.imageshack.us/img138/5230/snowh.png'), url('http://img594.imageshack.us/img594/9146/snow3q.png'), url('http://img196.imageshack.us/img196/5065/snow2l.png');
    -webkit-animation: snow 20s linear infinite;
    -moz-animation: snow 20s linear infinite;
    -ms-animation: snow 20s linear infinite;
    animation: snow 20s linear infinite;
}*/

#container {
    width: 800px;
    margin: 200px auto;
    text-align: center;
    color: white;
    font: 100px/1 'Spirax', cursive;
    text-shadow: 0px 0px 4px rgba(0,0,0, 0.5);
}

#container p { font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif }
4

2 回答 2

1

在这种情况下,诀窍是在 div 和动画帧中将背景颜色设置为透明。小提琴:http: //jsfiddle.net/f92gB/

HTML:

<body>
    <div id="container"></div>
</body>

CSS:

* {
    margin: 0;
    padding: 0;
}

a {
    color: white;
    font-style: italic;
}

/*Keyframes*/

@keyframes snow { 
    0% { background-position: 0px 0px, 0px 0px, 0px 0px }

    100% { background-position: 500px 1000px, 400px 400px, 300px 300px }
}

@-moz-keyframes snow { 
    0% { background-position: 0px 0px, 0px 0px, 0px 0px }

    100% { background-position: 500px 1000px, 400px 400px, 300px 300px }
}

@-webkit-keyframes snow { 
    0% { background-position: 0px 0px, 0px 0px, 0px 0px }

    50% { background-color: transparent }

    100% {
        background-position: 500px 1000px, 400px 400px, 300px 300px;
        background-color: transparent;
    }
}

@-ms-keyframes snow { 
    0% { background-position: 0px 0px, 0px 0px, 0px 0px }

    100% { background-position: 500px 1000px, 400px 400px, 300px 300px }
}

body {
    background-image: url("http://s17.postimg.org/9htu61zjj/background.jpg");
    background-size: cover;
    height: 500px;

}

#container {
    height:500px;
    margin: 0;
    text-align: center;
    color: white;
    font: 100px/1 'Spirax', cursive;
    text-shadow: 0px 0px 4px rgba(0,0,0, 0.5);
    background-color: transparent;
    background-image: url('http://img138.imageshack.us/img138/5230/snowh.png'), url('http://img594.imageshack.us/img594/9146/snow3q.png'), url('http://img196.imageshack.us/img196/5065/snow2l.png');
    -webkit-animation: snow 20s linear infinite;
    -moz-animation: snow 20s linear infinite;
    -ms-animation: snow 20s linear infinite;
    animation: snow 20s linear infinite;
}
于 2013-11-09T20:03:56.557 回答
0

您可以使用此 jQuery 插件在您的页面上设置完整且响应式的背景图像,只需按照此链接中的说明进行操作。

http://johnpatrickgiven.com/jquery/background-resize/

于 2013-11-09T19:38:35.807 回答