我正在使用流沙进行可排序的投资组合页面,并且需要使用第 n 个子元素删除每三个元素的左填充,我还必须添加鼠标悬停和鼠标退出效果。这是我目前拥有的:
$holder.quicksand($filteredData, {
duration: 200,
easing: 'easeInOutQuad'
}, function () {
$("#center_content .portfolio .tiles_holder .four img").mouseover(function () {
$(this).fadeTo("fast", 0.3, function () {
$('ul.tiles_holder li:nth-child(3n+1)').css("marginLeft", "0");
});
}).mouseout(function () {
$(this).fadeTo("fast", 1, function () {
$('ul.tiles_holder li:nth-child(3n+1)').css("marginLeft", "0");
});
});
});
但是发生的情况是,在鼠标悬停/退出事件发生之前,边距不会被删除。如何改进代码?
由于您没有发布任何html,因此很难确切地说,但似乎您需要将流沙回调更改为:
$holder.quicksand($filteredData, {
duration: 200,
easing: 'easeInOutQuad'
}, function () {
$('ul.tiles_holder li:nth-child(3n+1)').css("marginLeft", "0");
$("#center_content .portfolio .tiles_holder .four img").mouseover(function () {
$(this).fadeTo("fast", 0.3);
}).mouseout(function () {
$(this).fadeTo("fast", 1);
});
});