去掉iframe水平滚动条

20

我想要移除iframe中的水平滚动条,只需要垂直滚动条来查看内容。我的代码如下:

<iframe height='514' width='790' 
        marginwidth='0' marginheight='0' 
        frameborder='0' 
        overflow-y='scroll' 
        overflow-x='hidden'>
</iframe>

请有人解决我的问题,提前致谢。


1
请问您能否接受您认为最正确的答案,或者编写您自己的答案并接受它? - Max von Hippel
5个回答

51
在iframe页面本身中添加以下内容:
body {
    overflow-x:hidden;
    height:100%; //optional, but it can't hurt.
}

5
“在iframe页面本身”这是其他答案缺失的有价值的信息,谢谢! - Matthias
1
@Shankaralwar:请接受这个答案作为解决方案,感谢您尊重这个社区及其规则。 - basZero
1
你必须将可选的注释放入 /* */ 中,因为这是在 CSS 中进行注释的方式。 - Svetoslav Marinov

2
如果您使用支持CSS3的浏览器,可以使用overflow-x属性。
#my-iframe
{
   overflow-x:hidden;
}

0

尝试将滚动属性设置为“no”

<iframe scrolling="no" ..............> </iframe>

0

这里有一个IFrame自适应脚本。

然而,如果您使用SSL,则无法使用脚本在框架和主窗口之间进行通信。它会显示“访问被拒绝”。 :-(


-10

解决方案是:

style="overflow-x:hidden;
overflow-y:scroll;

在包含在iframe上的页面的标签<body>

查看此链接页面

敬礼,Raffaele。


9
请不要在原始答案提供两年后稍微修改并重复相同的回答。 - Behrang
我没有在其他地方看到这个答案?提供的答案都不起作用,但这个答案起作用了。 - Mark Deven

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