Bootstrap collapse() and flash of unhidden content

笑着哭i 提交于 2019-12-13 03:24:49

问题


Using Twitter Bootstrap framework, I'm using $('#foo').collapse() to make an FAQ with collapsable answers that are hidden by default, and then visible when you click the question.

The problem is that I get a flash of all the content before the .collapse() is initialized.

I can't hide the content in advance (via display: none), otherwise the collapse function doesn't know the height of the boxes and collapsing/expanding doesn't work.

I think this could be solved if $('#foo').collapse() didn't animate the initial collapse, and just instantly hid the elements. Any idea on how to do that (or other solutions)?

Here's a fiddle to play with: http://jsfiddle.net/DHZNv/44/

Thanks!


回答1:


Is this the behavior you want?

http://jsfiddle.net/DHZNv/45/



来源:https://stackoverflow.com/questions/11164172/bootstrap-collapse-and-flash-of-unhidden-content

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