jQuery图像悬停问题

时间:2013-07-02 19:37:11

标签: jquery css image

我正在使用jQuery,我正试图用鼠标做一些事情。当我将鼠标悬停在图像上时,图像会上升并显示下面的一个小文本,但我该怎么做?当我在图像上制作鼠标时图像会上升,但是当我将鼠标悬停在div上时,那么这个洞就会出现空间。有办法阻止这个吗?

$(".aImgContainer img").mouseover(function(){
    $(this).css({"transform":"translateY(-40px)"});
});

$(".aImgContainer img").mouseout(function(){
    $(this).css({"transform":"translateY(0px)"});
});

http://jsfiddle.net/mRHa5/

2 个答案:

答案 0 :(得分:2)

你去了:jsFiddle

我已将鼠标事件更改为容器.colofoonFoto而不是img。问题是,当你徘徊图像并且它上升时 - 你的鼠标不再在它上面

答案 1 :(得分:0)

尝试更改顶部位置而不是翻译?我也不得不调整一些css规则。

$(".colofoonFoto").mouseover(function(){
    $(this).find('img').css({"top":"-40px"});
});

$(".colofoonFoto").mouseout(function(){
    $(this).find('img').css({"top":"0"});
});

http://jsfiddle.net/carasin/AraQT/2/

相关问题