2011-11-17 30 views
6

我想顯示/隱藏使用jQuery左至右一段文字。jQuery的動畫slideLeft沒有文字環繞

我使用

$('#text').animate({ 
    width: ['toggle', 'swing'] 
}); 

但是我看到,該段包裝作爲動畫正在發生的事情。它看起來很醜。

爲的不期望的效果的例子參見this js fiddle

你怎麼會建議得到同樣的效果,但沒有包裝? (像.slideUp()/slideDown())...

感謝所有幫助

回答

3

試試這個:

CSS:

#wrap{ 
width:200px; 
    overflow: Hidden; 
} 
#text{ 
width:200px; 
} 

腳本:

setTimeout(
function(){ 
    $('#wrap').animate(// Changed to slide the wrap instead of the #text 
     { 
      width: ['toggle', 'swing'] 
     }) 
    }, 
1000); 

http://jsfiddle.net/RDsqy/2/