【问题标题】:Where does the width of this iframe come from?这个 iframe 的宽度从何而来?
【发布时间】:2011-08-03 06:50:45
【问题描述】:

另一个与 Facebook “Like” iframe 相关的问题:我根本不明白它的宽度从何而来。看下面的代码

<html>
<body>
Test<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.google.com&amp;send=false&amp;layout=button_count&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:21px;" allowTransparency="true"></iframe>Test
</body>
</html>

这是在页面中包含Facebook's "Like" button 的最小演示。您会注意到按钮周围的“测试”字样相距很远。检查器工具显示 iframe 的宽度正好是 300 像素。但是,浏览 iframe 的 DOM 树时,我找不到会导致 iframe 扩展到该宽度的单个元素或样式。 iframe 中加载的页面使用的任何 CSS 都没有提到任何与 300px 相关的内容。

这对我来说看起来很奇怪,但在浏览器中是一致的。最终,我当然希望 iframe 能够简单地适应其内容(请参阅我之前的问题),但现在,我很乐意知道为什么它首先会扩展到 300px 宽度。

【问题讨论】:

标签: html iframe facebook-like


【解决方案1】:

至少我终于解开了这个谜:

300px x 150px 是 Firefox、Chrome 和其他一些浏览器中的默认 iframe 尺寸。很遗憾,检查员没有表明这一点。

【讨论】:

  • 它仍然被维护。我记得并回来接受,谢谢。
猜你喜欢
  • 2011-12-10
  • 1970-01-01
  • 2015-05-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-02-03
  • 1970-01-01
  • 2014-01-31
相关资源
最近更新 更多