2013-05-26 54 views
5

很多其他問題,但似乎都沒有適用。我敢肯定,這是簡單的東西,但像我期待這不起作用:jquery「動畫」z-index不起作用?

$('#conflictsPane').css('left','600px') 
    .css('z-index', '1') 
    .animate({ left: "750px" }, 'slow') 
    .css('z-index', '101') 
    .animate({ left: "720px" }, 'fast'); 

我期待它從後面另一個元素滑出再滑回原位,在這一點。它工作得很好,除了似乎完全忽略了第一次分配zindex。我的另一個元素是100.如上所述,它從頂部開始並結束於頂部。如果我將101更改爲99,則它將從下開始並結束。我假設它不會像我期待的那樣阻塞。

我試着添加一個延遲(然後一堆延遲),但它沒有效果。

回答

4

該做的工作:

$('#conflictsPane') 
    .css('left', '600px') 
    .css('z-index', 1) 
    .animate({ left: "750px" }, 'slow', function() { 
     $(this).css('z-index', 101) 
    }) 
    .animate({ left: "720px" }, 'fast');