【发布时间】: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&send=false&layout=button_count&show_faces=false&action=like&colorscheme=light&font&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