2010-10-14 157 views
7

我有一个iframe,我希望启用水平滚动条,但禁用垂直滚动条。删除垂直滚动条,在Chrome中保持iframe中的水平滚动条

我有风格这样的iframe:overflow-y:hidden; overflow-x:auto;

这只是正常在Firefox,而不是浏览器。有没有什么解决方法可以让Chrome在Chrome中运行?

更新: 我已经过渡到使用溢出的表格单元而不是iframe。我不知道这是否会让它更容易或更难解决垂直滚动问题。

+1

[Safari/Chrome(Webkit)的可能重复 - 无法隐藏iframe垂直滚动条](http://stackoverflow.com/questions/1691873/safari-chrome-webkit-cannot-hide-iframe-vertical-scrollbar)。两者都标记为Chrome/webkit。 – 2014-02-13 12:38:39

回答

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

添加父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> 

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