visualWidth和visualHeight是怎么来的??为什么没有效果
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
#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)
}
}
</style>
</head>
<body>
<button>开始飘花</button>
<div id="snowflake"></div>
<script src="jquery-3.0.0.min.js"></script>
<script>
$(function() {
var snowflakeURl = [
'images/1.png',
'images/2.png',
'images/3.png',
'images/4.png',
'images/5.png',
'images/6.png'
];
function snowflake() {
var box = $("#snowflake");
function getImagesName() {
return snowflakeURl[[Math.floor(Math.random() * 6)]];
}
function createSnowBox() {
var url = getImagesName();
return $('<div />').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
});
// 加入到容器
box.append($flake);
// 开始执行动画
$flake.transition({
top: endPositionTop,
left: endPositionLeft,
opacity: 0.7
}, duration, 'ease-out', function() {
$(this).remove(); //结束后删除
});
}, 200);
}
$("button").click(function() {
snowflake();
console.log(createSnowBox);
});
});
</script>
</body>
</html>
visualWidth和visualHeight是怎么来的??我光写飘雪花的为什么没有动画出来