我建議代替使用animate()
:
$('div').click(
function() {
$(this).animate({
'height': 0,
'opacity': 0
}, 750, function() {
$(this).remove();
});
});
JS Fiddle demo。
編輯納入一個jQuery/CSS的解決方案:
更改爲.item
的CSS,包括以下內容:
.item{
/* other css removed for brevity */
-webkit-transition: all 1s linear;
-moz-transition: all 1s linear;
-o-transition: all 1s linear;
-ms-transition: all 1s linear;
transition: all 1s linear;
}
並更改a.hidden
以下幾點:
.hidden {
width: 0; /* reset everything that might affect the size/visibility */
height: 0;
padding: 0;
margin: 0;
opacity: 0;
-webkit-transition: all 1s linear;
-moz-transition: all 1s linear;
-o-transition: all 1s linear;
-ms-transition: all 1s linear;
transition: all 1s linear;
}
使用以下jQuery:
// content animate
$('#work-container > div[class*=hidden]').addClass('hidden');
return false;
JS Fiddle demo。
然後,一切似乎按你的想法工作。雖然我沒有試圖按照上面的塊中的.addClass('visible')
做什麼,但我放棄了它。
這確實需要一個支持CSS轉換的瀏覽器(並且支持opacity
),所以它可能不適合您的使用情況。
你有演示嗎?或者,至少,我們可以將一些代表性的HTML複製並粘貼到演示中? – 2012-04-18 15:49:31
PLZ提供了一個jsfiddle http://www.jsfiddle.net – undefined 2012-04-18 15:50:33
你想要比它動畫更多? http://jsfiddle.net/Ccswn/5/ – undefined 2012-04-18 16:04:34