在Chrome浏览器中的iframe中移除垂直滚动条,保留水平滚动条。

9

我有一个iframe,希望启用水平滚动条,但禁用垂直滚动条。

我已将iframe样式设置为:overflow-y:hidden; overflow-x:auto;

这在FireFox中可以正常工作,但在Chrome中不行。是否有任何解决办法可让它在Chrome中工作?

更新:我已转而使用带溢出的表格单元格,而不是iframe。我不知道这是否会使解决那个垂直滚动问题更容易或更难。


1
可能是重复的问题:Safari/Chrome (Webkit) - 无法隐藏iframe垂直滚动条。两个都标记为Chrome / Webkit。 - Ciro Santilli OurBigBook.com
4个回答

9

2
这在任何浏览器中都可以正常工作。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> 
<title>Untitled 1</title> 
</head> 
<style type="text/css"> 
#test iframe { 
width: 100%; 
height: 100%; 
border: none; } 

#test { 
width: 100%; 
height: 3530px; 
padding: 0; 
overflow: hidden; } 

</style> 

<body style="margin:0;"> 
<div id="test"> 
<iframe src="http://stackoverflow.com/" scrolling="no">
</iframe> 
</div> 
</body> 
</html>

0

真遗憾,我会寻找其他的东西并告诉你! - Trufa

0
将父级 div 元素添加到 iframe 中,如下所示:
<div style='overflow: hidden; width: 600px; height: 400px;'>
    <iframe src='http://www.website.com/index.html' style='overflow-y: hidden;' width='580' height='400' frameborder='0' seamless='seamless'></iframe>
</div>

它将隐藏垂直滚动条,但用户仍然可以使用“向上翻页”、“向下翻页”和箭头键选项进行垂直滚动。


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