HTML iframe - 禁用滚动 [英] HTML iframe - disable scroll
问题描述
我的网站中有以下 iframe:
I have following iframe in my site:
<iframe src="<<URL>>" height="800" width="800" sandbox="allow-same-origin allow-scripts allow-forms" scrolling="no" style="overflow: hidden"></iframe>
它有滚动条.
如何摆脱它们?
And it has scrolling bars.
How to get rid of them?
推荐答案
不幸的是,我认为仅使用 HTML 和 CSS 属性完全符合 HTML5 是不可能的.然而幸运的是,大多数浏览器仍然支持 scrolling
属性(该属性已从 HTML5 规范).
Unfortunately I do not believe it's possible in fully-conforming HTML5 with just HTML and CSS properties. Fortunately however, most browsers do still support the scrolling
property (which was removed from the HTML5 specification).
overflow
不是 HTML5 的解决方案,因为唯一一个错误地支持的现代浏览器是 Firefox.
overflow
isn't a solution for HTML5 as the only modern browser which wrongly supports this is Firefox.
目前的解决方案是将两者结合起来:
A current solution would be to combine the two:
<iframe src="" scrolling="no"></iframe>
iframe {
overflow: hidden;
}
但这可能会随着浏览器的更新而过时.您可能需要检查此 JavaScript 解决方案:http://www.christersvensson.com/html-tool/iframe.htm
But this could be rendered obsolete as browsers update. You may want to check this for a JavaScript solution: http://www.christersvensson.com/html-tool/iframe.htm
我已经检查过,scrolling="no"
将在 IE10、Chrome 25 和 Opera 12.12 中工作.
I've checked and scrolling="no"
will work in IE10, Chrome 25 and Opera 12.12.
这篇关于HTML iframe - 禁用滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!