最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery animation slideLeft without text wrapping - Stack Overflow

programmeradmin1浏览0评论

I would like to show / hide a paragraph of text using jQuery left to right.

I'm using

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

However I am seeing that the paragraph wraps as the animation is happening. And it looks ugly.

See this js fiddle for an example of the undesired effect.

How would you remend getting the same effect but with no wrapping? (Like .slideUp() / slideDown())...

Thanks for any help

I would like to show / hide a paragraph of text using jQuery left to right.

I'm using

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

However I am seeing that the paragraph wraps as the animation is happening. And it looks ugly.

See this js fiddle for an example of the undesired effect.

How would you remend getting the same effect but with no wrapping? (Like .slideUp() / slideDown())...

Thanks for any help

Share Improve this question edited Nov 17, 2011 at 10:23 Manse 38.1k11 gold badges86 silver badges111 bronze badges asked Nov 17, 2011 at 10:17 ChrisChris 6,24612 gold badges50 silver badges62 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

You need to set overflow: hidden on the container, and then apply the animation to the container.

Updated fiddle with fix here

Try this:

CSS:

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

Script:

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

http://jsfiddle/RDsqy/2/

发布评论

评论列表(0)

  1. 暂无评论