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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
| <!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="Author" content="Daniel Hagnoul">
<title>Forum jQuery</title>
<style>
/* Base */
div,p,h1,h2,h3,h4,h5,h6,ul,ol,dl,form,table,img {margin:0px; padding:0px; }
body {background-color:#dcdcdc; color:#000000; font-family:sans-serif; font-size:medium; font-style:normal; font-weight:normal; line-height:normal; letter-spacing:normal; }
h1,h2,h3,h4,h5 {font-family:serif; padding:6px; }
p, div, td {word-wrap:break-word; }
pre, code {white-space:pre-wrap; word-wrap:break-word; }
img, input, textarea, select {max-width:100%; }
img {border:none; }
h1 {font-size:2em; text-shadow: 4px 4px 4px #bbbbbb; text-align:center; }
p {padding:6px; }
ul,ol,dl {list-style:none; padding-left:6px; padding-top:6px; }
li {padding-bottom:6px; }
.conteneur {width:95%; min-width:800px; min-height:400px; margin:12px auto; background-color:#FFFFFF; color:#000000; border:1px solid #666666; }
/* bottomPanel */
#mondiv {
background-image:url('http://danielhagnoul.developpez.com/images/imageTest.png');
background-position:-30px 0px;
background-repeat: no-repeat;
height: 22px;
width: 120px;
border:1px solid red;
}
#mondivVert1 {
background-image:url('http://danielhagnoul.developpez.com/images/imageTest.png');
background-position:0px 70%;
background-repeat: no-repeat;
height: 120px;
width: 22px;
border:1px solid red;
}
#mondivVert2 {
background-image:url('http://danielhagnoul.developpez.com/images/imageTest.png');
background-position:0px 130%;
background-repeat: no-repeat;
height: 120px;
width: 22px;
border:1px solid red;
}
#mondivVert3 {
background-image:url('http://danielhagnoul.developpez.com/images/imageTest.png');
background-position:0px -30%;
background-repeat: no-repeat;
height: 120px;
width: 22px;
border:1px solid red;
}
</style>
</head>
<body>
<h1>Forum jQuery</h1>
<section class="conteneur">
<div id="mondiv"></div>
<br/>
<div id="mondivVert1"></div>
<br/>
<div id="mondivVert2"></div>
<br/>
<div id="mondivVert3"></div>
</section>
<footer itemscope itemtype="http://data-vocabulary.org/Person">
<time datetime="2011-06-06T22:45:00.000+02:00" pubdate>2011-06-06</time> <span itemprop="name">Daniel Hagnoul</span> <a href="http://www.developpez.net/forums/u285162/danielhagnoul/" itemprop="url">@danielhagnoul</a>
</footer>
<script charset="utf-8" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
<script>
/**
* @author Alexander Farkas
* v. 1.02
*/
(function($) {
$.extend($.fx.step,{
backgroundPosition: function(fx) {
if (fx.state === 0 && typeof fx.end == 'string') {
var start = $.curCSS(fx.elem,'backgroundPosition');
start = toArray(start);
fx.start = [start[0],start[2]];
var end = toArray(fx.end);
fx.end = [end[0],end[2]];
fx.unit = [end[1],end[3]];
}
var nowPosX = [];
nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];
nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];
fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];
function toArray(strg){
strg = strg.replace(/left|top/g,'0px');
strg = strg.replace(/right|bottom/g,'100%');
strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");
var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);
return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];
}
}
});
})(jQuery);
$(function(){
$('#mondiv').hover(
function(){
$(this).animate({"background-position": "(0px 0px)"}, 500);
},
function(){
$(this).animate({"background-position": "(-30px top)"}, 500);
}
);
$('#mondivVert1').hover(
function(){
$(this).animate({"background-position": "(0px 100%)"}, 500);
},
function(){
$(this).animate({"background-position": "(0px 70%)"}, 500);
}
);
$('#mondivVert2').hover(
function(){
$(this).animate({"background-position": "(0px 100%)"}, 500);
},
function(){
$(this).animate({"background-position": "(0px 130%)"}, 500);
}
);
$('#mondivVert3').hover(
function(){
$(this).animate({"background-position": "(0px 100%)"}, 500);
},
function(){
$(this).animate({"background-position": "(0px -30%)"}, 500);
}
);
});
</script>
</body>
</html> |
Partager