cela pourrait être une entrée de ce que vous recherchez:
$(document).ready(function() {
$('#tab-to-animate').hover(function() {
// this anonymous function is invoked when
// the mouseover event of the tab is fired
// you will need to adjust the second px value to
// fit the dimensions of your image
$(this).css('backgroundPosition', 'center 0px');
}, function() {
// this anonymous function is invoked when
// the mouseout event of the tab is fired
// you will need to adjust the second px value to
// fit the dimensions of your image
$(this).css('backgroundPosition', 'center -20px');
});
});
mauvaise lecture désolé la question de ce code devrait faire passer la div dans son ensemble en supposant que vous l'avez poussé vers le bas en utilisant d'abord la position: relative propriété css.
$(document).ready(function() {
$('.recruiterLink').hover(function() {
$(this).css({
'position' : 'relative',
'top' : 0
});
}, function() {
$(this).css({
'position' : 'relative',
'top' : 20
});
});
});
Cela fonctionnerait-il encore si le div.recruiterLink était en position absolue? – Anthony
Oui! Cela fonctionnera si c'est relatif ou absolu. Mais alors vous devriez avoir un wrapper autour de votre menu, avec une position relative afin que le bouton ne soit pas positionné absolument sur la page, mais sur son wrapper. – Flipke