Html HTML5:iframe 没有滚动?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18470015/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML5 : Iframe No scrolling?
提问by jave.web
When it comes to HTML5, scrolling attribute is no longer supported - but I still need to remove the scroll bars - how to do that?
当涉及到 HTML5 时,不再支持滚动属性 - 但我仍然需要删除滚动条 - 怎么做?
回答by jave.web
In HTML5 there is no scrolling attribute because "its function is better handled by CSS" see http://www.w3.org/TR/html5-diff/for other changes. Well and the CSS solution:
在 HTML5 中没有滚动属性,因为“CSS 可以更好地处理它的功能”,请参阅http://www.w3.org/TR/html5-diff/了解其他更改。好吧,CSS 解决方案:
CSS solution:
CSS 解决方案:
HTML4's scrolling="no"
is kind of an alias of the CSS's overflow: hidden
, to do so it is important to set size attributes width/height:
HTML4scrolling="no"
是 CSS 的一种别名,overflow: hidden
为此设置大小属性宽度/高度很重要:
iframe.noScrolling{
width: 250px; /*or any other size*/
height: 300px; /*or any other size*/
overflow: hidden;
}
Add this class to your iframe and you're done:
将此类添加到您的 iframe 中,您就完成了:
<iframe src="http://www.example.com/" class="noScrolling"></iframe>
! IMPORTANT NOTE ! :overflow: hidden
for <iframe>
is not fully supported by all modern browsers yet(even chrome doesn't support it yet) so for now (2013) it's still better to use Transitionalversion and use scrolling="no"
and overflow:hidden
at the same time :)
!重要的提示 !:overflow: hidden
对<iframe>
未完全通过所有现代浏览器都支持,但(即使Chrome不支持它尚未)所以现在(2013),它仍然是更好地使用过渡版和使用scrolling="no"
,并overflow:hidden
在同一时间:)
UPDATE 2020:the above is still true, oveflow for iframes is still not supported by all majors
2020 年更新:以上仍然正确,所有专业仍然不支持 iframe 的 oveflow