Vous allez devoir combiner quelques fonctions jQuery.
La fonction d'animation à: http://api.jquery.com/animate/
La souris sur fonction: http://api.jquery.com/mouseover/
La souris désactivante: http://api.jquery.com/mouseout/
Have « divs factices » où la souris sur est détecté vrai mouvement div de leur carte d'identité hors de la vue en utilisant l'animer, et de le ramener avec mouseout
J'ai trouvé cela intéressant si codé pour moi-même ... Je l'ai fait comme ci-dessous:
<style type="text/css">
body {
overflow:hidden;
}
.leaf {
position:relative;
background-color:#0F0;
height: 100px;
width: 100px;
}
.branch {
display:inline-block;
background-color:#F00;
height: 100px;
width: 100px;
}
</style>
<script type="text/javascript">
$(function(){
var w = $(document).width();
var h = $(document).height();
var r = 250;
$(".branch").hover(function() {
var rand = Math.random();
var x,y;
if(rand<0.25) {
x = w;
y = h*Math.random();
} else if(rand<0.5) {
x = -w;
y = h*Math.random();
} else if(rand<0.75) {
x = w*Math.random();
y = h;
} else {
x = w*Math.random();
y = -h;
}
$(this).children().animate({left: x, top: y});
}, function() {
$(this).children().animate({left: '0', top: '0'});
})
});
</script>
<div class="wrap">
<div class="branch"><div class="leaf"></div></div><!-- etc -->
</div>
Cela ne devrait pas être étiqueté 'php', il s'agit d'un problème côté client sans rapport avec la langue de votre serveur. –
Balise php remplacée par javascript car la solution impliquerait probablement que (avec ou sans jQuery) – akauppi