javascript - 在加载隐藏的 div 时保留空白

标签 javascript jquery css html

在下面的代码中,一个 div 被隐藏,直到它从第 3 方服务器获得 OK,然后它通过 jquery 呈现。目的是营造平稳加载的印象。问题是这个 div 下面的段落在 div 加载后被下推,这违背了这个技巧的目的。解决该问题的最佳方法是什么?

http://jsfiddle.net/Sh7aA/7/

<div id="fb-root"></div>
<p style="text-align:center">Follow us!</p>
<center style="display: none;" id="social">
    <div class="g-plusone" data-size="medium"></div>
    <div class="fb-like" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>
</center>

<p style="text-align:center">Test paragraph of text<br>
Paragarph continued</p>

最佳答案

设置加载内容的容器的min-height,以匹配加载内容的高度。

关于javascript - 在加载隐藏的 div 时保留空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21007982/

相关文章:

javascript - Nodejs http.createServer 回调

javascript - 消息关闭后不会再次显示

javascript - 使用 Featherlight.js 禁用右键单击

css - Bootstrap 3 上的输入宽度

javascript - 将多个字符串传递给 stringByEvaluatingJavaScriptFromString 时出现问题

jquery - 未捕获的类型错误 : ((x. event.special[i.origType] || (中间值)).handle || i.handler).apply 不是函数

javascript - CSS 层,标题位于图像层下

javascript - 网络应用程序可以转换为谷歌浏览器应用程序吗?

javascript - Bootstrap : Header moves when modal opens

javascript - 通过 View 中的 @ViewChild 调用组件上的方法到 QueryList