更新时间:2023-01-08 19:19:39
1)与其立即执行回调中的悬停项目的fadeIn,不如执行它.这样可以防止白色背景通过以下方式显示:
1) Rather than do the fadeIn of the hover item on the callback, do it immediately. This will prevent the white background showing through:
$('.grid-box .phase-1').fadeOut(300);
$('.grid-box .phase-2').fadeIn(300);
2)最简单的方法是在缩略图容器上指定大小,并在其上添加overflow: hidden;
.
2) The easiest way to do this is to specify a size on the thumbnail container and the add overflow: hidden;
to it.
3)最后,以下代码将确保仅将鼠标悬停在div内的元素受影响:
3) Finally the following code will make sure only the elements contained within the hovered-over div will be affected:
$(function(){
$('.grid-box').hover(
function(){
$('.phase-1', this).fadeOut(300);
$('.phase-2', this).fadeIn(300);
},
function(){
$('.phase-2', this).fadeOut(300)
$('.phase-1', this).fadeIn(300);
}
);
});