1、调用CSS样式:
<link rel="stylesheet" href="style.css" />
2、调用JS插件代码:
<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/jqfloat.min.js"></script>
3.JS动画实例代码:
<script>
$(document).ready(function() {
$('.cloud').each(function() {
$(this).jqFloat({
width:Math.floor(Math.random()*10)*10,
height:10,
speed:Math.floor(Math.random()*10)*100 + 500
});
});
$('#sun').jqFloat({
width:10,
height:50,
speed:1800
});
$('.butterfly').jqFloat({
width:400,
height:100,
speed:1500
});
$('#snail, #message').jqFloat('stop',{
width:5,
height:0,
speed:30
});
$('#snail, #message').hover(function() {
$(this).jqFloat('play');
}, function() {
$(this).jqFloat('stop');
});
var clicked = false;
//define balloon attribute
$('#balloon').jqFloat('stop',{
width:5,
height:30,
speed:1500,
minHeight:300
});
$('#balloon').on('click', function() {
clicked = !clicked;
if(clicked)
$(this).jqFloat('play');
else
$(this).jqFloat('stop');
});
});
</script>