简体   繁体   English

在某些背景图片上使用css3的降雪效果

[英]Snowfall effect using css3 on some background image

I have developed web page which is having snowfall effect using CSS3 and it is working fine. 我已经开发了使用CSS3具有降雪效果的网页,并且效果很好。 Refereed this link : - 引用了此链接:-
http://designshack.net/articles/css/make-it-snow-on-your-website-with-css-keyframe-animations/ http://designshack.net/articles/css/make-it-snow-on-your-website-with-css-keyframe-animations/

But I am not able to do it with predefined background. 但是我无法在预定义的背景下执行此操作。 I am having one background image and i want to fall snow on that image. 我有一个背景图像,我想在该图像上下雪。 I am not sure how I should achieve that.Tried a lot. 我不确定应该如何实现这一目标。 Can anybody share his/her idea regarding this? 有人可以分享他/她的想法吗?

    body {
    background: url('configAssets/images/img.png'), url('configAssets/images/snow.png'), 
   url('configAssets/images/snow3.png'), url('configAssets/images/snow2.png');
}

@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;}
 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;}
}

.snow {
    -webkit-animation: snow 40s linear infinite;
    -moz-animation: snow 40s linear infinite;
    -ms-animation: snow 40s linear infinite;
    animation: snow 40s linear infinite;
}

You need to make sure your original background image is the last in line. 您需要确保原始背景图像是最后一行。 See Stacking Order of Multiple Backgrounds 请参阅多个背景的堆叠顺序

background-image: url('snow.png'), url('snow2.png'), url('snow3.png'),
 url('configAssets/images/img.png');
body {
    background-color: #6b92b9;
    background-image: url('snow.png'), url('snow2.png'), url('snow3.png'),url('configAssets/images/img.png');

    -webkit-animation: snow 20s linear infinite;
    -moz-animation: snow 20s linear infinite;
    -ms-animation: snow 20s linear infinite;
    animation: snow 20s linear infinite;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM