<div id='content'> <!-- 飘花 --> <div id="snowflake"></div> </div>
#content { width: 100%; height: 100%; top: 42px;
overflow: hidden; position: absolute; }
#snowflake { width: 100%; height: 100%; position: absolute; top: 0; left: 0; overflow: hidden; }
.snowRoll { position: absolute; opacity: 0; -webkit-animation-name: mysnow; -webkit-animation-duration: 20s; -moz-animation-name: mysnow; -moz-animation-duration: 20s; height: 80px; }
@-webkit-keyframes mysnow { 0% {
bottom: 100%;
}
50% {
-webkit-transform: rotate(1080deg);
}
100% {
-webkit-transform: rotate(0deg) translate3d(50px, 50px, 50px);
}
}
@-moz-keyframes mysnow { 0% {
bottom: 100%;
}
50% {
-moz-transform: rotate(1080deg);
}
100% {
-moz-transform: rotate(0deg) translate3d(50px, 50px, 50px);
}
}
<script type="text/javascript">
$(function() {
var snowflakeURl = [
'http://images.cnblogs.com/cnblogs_com/LoveOrHate/723567/o_1.png',
'http://images.cnblogs.com/cnblogs_com/LoveOrHate/723567/o_2.png',
'http://images.cnblogs.com/cnblogs_com/LoveOrHate/723567/o_3.png',
'http://images.cnblogs.com/cnblogs_com/LoveOrHate/723567/o_4.png',
'http://images.cnblogs.com/cnblogs_com/LoveOrHate/723567/o_5.png',
'http://images.cnblogs.com/cnblogs_com/LoveOrHate/723567/o_6.png'
] //js设置数组存储6张花瓣的图片
var container = $("#content");
visualWidth = container.width();
visualHeight = container.height();
//获取content的宽高
///////
//飘雪花 //
///////
function snowflake() {
// 雪花容器
var $flakeContainer = $('#snowflake');
// 随机六张图
function getImagesName() {
return snowflakeURl[[Math.floor(Math.random() * 6)]];
}
// 创建一个雪花元素
function createSnowBox() {
var url = getImagesName();
return $('<div class="snowbox" />').css({
'width': 41,
'height': 41,
'position': 'absolute',
'backgroundSize': 'cover',
'zIndex': 100000,
'top': '-41px',
'backgroundImage': 'url(' + url + ')'
}).addClass('snowRoll');
}
// 开始飘花
setInterval(function() {
// 运动的轨迹
var startPositionLeft = Math.random() * visualWidth - 100,
startOpacity = 1,
endPositionTop = visualHeight - 40,
endPositionLeft = startPositionLeft - 100 + Math.random() * 500,
duration = visualHeight * 10 + Math.random() * 5000;
// 随机透明度,不小于0.5
var randomStart = Math.random();
randomStart = randomStart < 0.5 ? startOpacity : randomStart;
// 创建一个雪花
var $flake = createSnowBox();
// 设计起点位置
$flake.css({
left: startPositionLeft,
opacity : randomStart
});
// 加入到容器
$flakeContainer.append($flake);
// 开始执行动画
$flake.transition({
top: endPositionTop,
left: endPositionLeft,
opacity: 0.7
}, duration, 'ease-out', function() {
$(this).remove() //结束后删除
});
}, 200);
}
snowflake()
//执行函数
})
</script>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有