Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一段文本嵌套在 div 标签中,当点击链接时,它应该展开并淡入文本。问题是,初始点击不会触发动画,它只是淡入作为回调函数的文本。
想不通这个 其他经历过这个问题的人谈论填充和 CSS,但这里不是这种情况。
http://jsfiddle.net/XPs2w/1/
问题是您的 div 的内容是display: none在第一次点击时。这意味着您的 div 基本上没有内容,这意味着它没有高度。所以你是从 0 高度到 0 高度的动画。动画第一次运行后,内容淡入。现在有了内容,动画高度实际上做了一些事情。
display: none
有可能给它一个静态高度:
http://jsfiddle.net/XPs2w/2/