jQuery slideToggle() applies display:block while sliding

我的未来我决定 提交于 2020-01-25 05:16:06

问题


I have a page that's like a discussion where you can make posts and reply to those posts. When there are more than 2 replies, I show the two most recent ones and hide the rest by default. There's a button that will let you expand/collapse the extra replies that uses jQuery's slideToggle function. It's operating on an unordered list of tables, where each table contains the comment along with the user's name and some other info.

Here's the problem: While the tables are actually sliding up or down, the first table in the list looks like its width has been set to auto, so it shrinks. Once it's done sliding, the formatting looks fine; it's just during the actual sliding that this happens. I'm assuming it's being set to 'display:block' or something during the slide but I don't know that for sure.

Is there a way to control what the display type is during the animation?

//this is what happens when you click the 'View all X replies' or 'Hide replies' button
        $(".expandOverflow").click(function()
    {
                $(".overflowlist" + overflowListTarget).slideToggle(16000/*, function(){$(this).css('display', 'inline');}*/);
    });

来源:https://stackoverflow.com/questions/5996318/jquery-slidetoggle-applies-displayblock-while-sliding

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!