問題描述
我有一個 IFRAME,隱藏在 css 和 html 中。它適用於 Firefox,但不適用於 Chrome /Safari
為什麼是這樣?
最佳解決思路
對,怎麼樣?
<iframe scrolling="no" src="http://www.google.com" width="400px" height="300"></iframe>
如 scrolling="no"
次佳解決思路
經過一個相當大的研究,我已經做了這個問題,我想釋出我的答案,我建議,可能是一個補充 Joonas 的答案:
<style>
iframe {
overflow:hidden;
}
</style>
(...)
<iframe scrolling="no" src="http://www.google.com" width="400px" height="300"></iframe>
我認為,應該提供 scrolling 和 overflow:hidden,儘管這個解決方案不能在 Chrome 和 HTML5 檔案的組閤中使用。 scrolling 屬性在 HTML5 中已棄用,overflow 屬性不會影響 Chrome 中的 iframe 。我假設後者是一個錯誤,因為 HTML5 specification 清楚地說:
In addition, HTML5 has none of the presentational attributes that were in HTML4 as their functions are better handled by CSS:
(…)
– nowrap attribute on td and th.
– rules attribute on table.
– scrolling attribute on iframe.
– size attribute on hr.
– type attribute on li, and ul.
(…)
很清楚 – 在 HTML5 scrolling 應該被 CSS overflow 替代。
參考文獻
注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。