html+CSS样式:雪花飘落背景(雪花为图片)

 

多种雪花图片,自由下落到底端渐变消失

 

 

html代码

<!DOCTYPE html>

<html style="background-color: black">

<head>

	<meta charset="UTF-8">

	<title>雪花飘落</title>

	<meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>

	<style>

			html,body {width: 100%;}

			#leafContainer

			{

				position: fixed;

				z-index: 2;

				width: 100%;

				height: 100%;

				top: 0;

				overflow: hidden;

			}


			#leafContainer > div

			{

				position: absolute;

				max-width: 100px;

				max-height: 100px;

				-webkit-animation-iteration-count: infinite, infinite;
				-webkit-animation-direction: normal, normal;

				-webkit-animation-timing-function: linear, ease-in;

			}


			#leafContainer > div > img

			{

				width: 100%;

				-webkit-animation-iteration-count: infinite;

				-webkit-animation-direction: alternate;

				-webkit-animation-timing-function: ease-in-out;

				-webkit-transform-origin: 50% -100%;

			}

			@-webkit-keyframes fade

			{

				0%   {

				opacity: 1;

			}

			95%

			{

				opacity: 1;

			}

			100%

			{

				opacity: 0;

			}

			}

			@-webkit-keyframes drop

			{

				0%   {

				-webkit-transform: translate(0px, -50px);

			}

			100%

			{

				-webkit-transform: translate(0px, 650px);

			}

			}

			@-webkit-keyframes clockwiseSpin

			{

				0%   {

				-webkit-transform: rotate(-50deg);

			}

			100%

			{

				-webkit-transform: rotate(50deg);

			}

			}

			@-webkit-keyframes counterclockwiseSpinAndFlip

			{

				0%   {

				-webkit-transform: scale(-1, 1) rotate(50deg);

			}

			100%

			{

				-webkit-transform: scale(-1, 1) rotate(-50deg);

			}

			}

		</style>

	<script>


		const NUMBER_OF_LEAVES = 50;

 

	function init()

		{

		    

		    var container = document.getElementById('leafContainer');

		   

		    for (var i = 0; i < NUMBER_OF_LEAVES; i++) 

		    {

		        container.appendChild(createALeaf());

		    }

		}



		function randomInteger(low, high)

		{

		    return low + Math.floor(Math.random() * (high - low));

		}



		 

		function randomFloat(low, high)

		{

		    return low + Math.random() * (high - low);

		}



		 

		function pixelValue(value)

		{

		    return value + 'px';

		}

		 

		function durationValue(value)

		{

		    return value + 's';

		}

		 

		function createALeaf()

		{

    

    var leafDiv = document.createElement('div');

    var image = document.createElement('img');

    



    image.src ='snow' + randomInteger(1, 5) + '.png';



    leafDiv.style.top = "-10px";





    leafDiv.style.left = pixelValue(randomInteger(0, 1000));

    

   

    var spinAnimationName = (Math.random() < 0.5) ? 'clockwiseSpin' : 'counterclockwiseSpinAndFlip';

    

    

    leafDiv.style.webkitAnimationName = 'fade, drop';

    image.style.webkitAnimationName = spinAnimationName;

    

   

    var fadeAndDropDuration = durationValue(randomFloat(5, 11));

   

    var spinDuration = durationValue(randomFloat(4, 8));

     

    leafDiv.style.webkitAnimationDuration = fadeAndDropDuration + ', ' + fadeAndDropDuration;



    var leafDelay = durationValue(randomFloat(0, 5));

    leafDiv.style.webkitAnimationDelay = leafDelay + ', ' + leafDelay;



    image.style.webkitAnimationDuration = spinDuration;

 

    leafDiv.appendChild(image);

 

    return leafDiv;

	}

 

		window.addEventListener('load', init);

		</script></head>

<body>

	<div id="leafContainer">

		</div>

</body>

</html>

 

images素材:4个,     能 。。。看清的吧。。

保存图片方法:鼠标放到雪花上(不要点,点开雪花是白色的你不一定能找到),右键—图片另存为 

 

喜欢的话点个赞吧~~

 

 

————————————————————————调皮的分割线4月9日更——————————————————————————————————————————————

 

各种通过html写成的类似ppt字体特效,
鼠标跟随特效
星空粒子背景,雪花背景,气泡背景,树叶飘落,烟花光束背景,
轮播图,3D轮播图
各种卡通动画效果
成型404界面
3D六面体(盒子)
翻书特效
画轴特效
翻书特效
返回顶部小插件
照片影集特效
登录界面
导航栏侧边栏
各种button样式
 
 
返回顶部                            3D六面体                                     鼠标绑定跟随                       星空粒子背景
                                         
 
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值