-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery16-animate.html
73 lines (73 loc) · 1.63 KB
/
jquery16-animate.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Efectos</title>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://www.bitstorm.org/jquery/color-animation/jquery.animate-colors-min.js"></script>
<script>
$(document).on('ready',function(){
//método animate: primer argumento es un objeto json
// segundo argumento es la duración en ms
//1-
/*
$('#caja1').animate({
'margin-bottom':0
},800)
*/
//2-definimos una función al terminar la animación
// esta segunda función cambia el margin-top
/*
$('#caja1').animate({
'margin-bottom':0
},800,function(){
$('#caja1').animate({
'margin-top':-100,
'opacity':0.5
})
})
*/
//Con el método animate solo podemos modificar valores numéricos
//Si quiero modificar un valor no numérico, como el color
//Hay un plugin para expandir la animación a colores
//bitstorm.org/jquery/color-animation
//agregamos el script arriba junto a jquery:
//<script src="http://www.bitstorm.org/jquery/color-animation/jquery.animate-colors-min.js">
/*
$('#caja1').animate({
'margin-bottom':0
},800,function(){
$('#caja1').animate({
'background-color':'#0FD',
'margin-top':-100,
'opacity':0.5
})
})
*/
});
</script>
<style>
body,html{
padding:100px;
}
div
{
display:block;
height:80px;
width: 400px;
margin:0 auto;
}
#caja1{
background: rgba(56,56,56,0.8);
margin-bottom: 100px;
}
#caja2{
background: rgba(89,69,36,0.8);
}
</style>
</head>
<body>
<div id="caja1">Hola</div>
<div id="caja2">Hola</div>
</body>
</html>