隐藏 IE 中的滚动条
在我们的 UI 应用程序中,我们使用 JSF 或 Prime faces 来实现这一点。 我们想隐藏应用程序的滚动条,但我们在 Internet Explorer 中很难实现这一点(我们使用的是 IE7)。
有什么办法可以阻止 Internet Explorer 中显示滚动条吗? 我尝试将 overflow:hidden;
放入 CSS 中,但它不起作用。
我几乎尝试了 DOM 中的每个节点,并将 width
/height
设置为 100%
,并设置 margin: 0px
,填充:0px
。似乎在 Firefox 中工作得很好,但在 IE7 中却不起作用?
In our application for UI we are using JSF or Prime faces for that.
We would like to hide the scrollbar for our application, but we are struggling to achieve this in Internet Explorer (We are using IE7).
Is there any way to prevent for displaying the scroll bar in Internet explorer?
I tried to put overflow: hidden;
in CSS,but it's not working.
I have tried nearly every node in the DOM and set width
/height
to 100%
, with margin: 0px
, padding: 0px
. Seems to work great in Firefox, but it doesn't work in IE7?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我无法提供简单的 CSS 解决方案,但如果您使用 jQuery,可以很容易地以这种方式将计算的宽度和高度设置为主体:
然后
也可以在 IE 中工作(至少在 IE9+ 中)。我的目标是使页面暂时不可滚动(当显示具有自己的滚动功能的自定义对话框时)。当自定义对话框关闭时,我将主体样式属性重置为其之前的状态(以删除计算的主体宽度和高度)。
I cannot provide plain CSS solution, but if you use jQuery, it is easy to set the computed width and height to the body this way:
and then
worked also in IE (at least in IE9+). My goal was to make page not scrollable temporarily (when custom dialog with own scrolling capability was shown). And when custom dialog was closed, I reset the body style attribute to its previous state (to remove the computed body width and height).
如果有人仍然需要解决方案,这个对我有用:
此更改允许在容器上滚动并隐藏 IE 上的栏。
另一方面,如果您想隐藏它并在用户再次滚动时再次显示它,您可以使用。
如果您不仅想从特定容器中完全隐藏它(滚动条),您可以使用:
在 IE 10 上测试 && 11.
参考
In case of anyone still needs a solution, this one worked for me:
This change allows scroll on the container and hides the bars on IE.
If on the other hand you want to hide it and show it again once the user scroll again you can use.
In case you want to hide it completely (the scrollbar) not only from a specific container you can use:
Tested on IE 10 && 11.
Reference
不看代码很难说!也就是说,您可以尝试使用 Microsoft 为 Internet Explorer 引入的“扩展属性”。
编辑:
您还可以尝试在CSS中设置html页面的overflow属性,如下所示。
Hard to say without seeing the code! Saying that, You could try use using the "Extended Attributes" that Microsoft introduced for Internet Explorer.
EDIT:
You could also try setting the overflow property of the html page in CSS like so.
这个 CSS 在 Chrome 和 IE 10 中都适用于我:
This CSS works for me both in Chrome and IE 10:
您可以使用此代码将其实现到主体中 -
如果不是这样,请查看布局并查看是否有任何容器具有不适当的宽度,这使得布局有点拉伸......
You may use this code implement it into body --
If not by that look into the layout and see if any container have a untoward width of something which is making the layout stretch a bit...
在尝试
overflow:hidden;
时,请先确保 IE 未处于兼容模式,然后再自责Make sure IE is not in compatibility mode before you beat yourself up while trying
overflow:hidden;
使用
这会自动隐藏滚动条,但在滚动时再次显示
https://developer.mozilla.org/en-US/docs/Web/CSS/-ms-overflow-style
use
This automatically hides the scollbar but shows it again when scrolling
https://developer.mozilla.org/en-US/docs/Web/CSS/-ms-overflow-style