如何移除iframe的滚动条?

17

如何移除iframe的滚动条?在Firefox中很容易,但我发现自己无法实现与所有主流浏览器兼容的效果。


请参考以下问答获取答案和解释:https://dev59.com/6WMl5IYBdhLWcg3wXF5f - jave.web
4个回答

42
如果 CSS 技术不起作用,尝试将属性 scrolling="no" 添加到 iframe HTML 标签中。
<iframe scrolling="no" src="..." >

各位先生,这就是我最终如何使动画gif保持动画效果,即使在IE的postback调用时也能如此。附加额外代码无法解决问题,延迟源加载也无济于事,但古老元素iFrame起了奇效。一旦去掉滚动条,它就像黄金一样好! - Lukas

16

CSS

iframe {
   overflow: hidden;
}

或者使用Coin_op的答案,它似乎更好。


但是如果您在IE兼容模式下检查它,它会重新出现,因此您必须将滚动条:'no' 添加到iframe本身。这个链接解释了它。http://www.dynamicdrive.com/forums/showthread.php?26750-Iframe-without-scrollbar - Lucky

5
除了Alex的答案之外,我还需要添加以下内容才能从FF和Chrome中删除水平工具栏。尽管应该可能在CSS中添加它,但是这是在i-frame页面中添加的:
    <style>
        iframe::-webkit-scrollbar {  
        display: none;
    }  
    </style>

0
<iframe runat="server" id="_theFrame"  src="url" width="100%" scrolling="no" height="200" frameborder="0" allowtransparency="true" marginwidth="0" marginheight="0" style="display: block; background: none repeat scroll 0% 0% transparent; width: 100%;" />

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接